fix checkbox + template

*now checkbox value update hidden input that is taken for backend, allowing to change checkbox values
*set same jinja logic for checkbox and hidden input to get same value on rendering
This commit is contained in:
BlasenhauerJ 2023-04-27 11:52:45 +02:00
parent 1e6cfe8b0e
commit d4fd4c4733
2 changed files with 11 additions and 3 deletions

View File

@ -24,6 +24,14 @@ class Checkbox {
checkboxEl.checked
? checkboxEl.setAttribute("value", "yes")
: checkboxEl.setAttribute("value", "no");
//set custom input hidden value
const newValue = checkboxEl.getAttribute("value");
const inpServ = checkboxEl
.closest("[data-checkbox-handler]")
.querySelector('input[type="hidden"]');
inpServ.setAttribute("value", newValue);
inpServ.value = newValue;
}
} catch (err) {}
});

View File

@ -186,9 +186,9 @@ data-plugin-item="{{plugin['id']}}"
disabled:border-gray-400 dark:disabled:bg-gray-800
dark:disabled:border-gray-800 disabled:text-gray-700
dark:disabled:text-gray-300" type="checkbox" data-pattern="{{value['regex']|safe}}"
value="{% if global_config[setting]['value'] %}
{{global_config[setting]['value']}} {% else %} {{value['default']}} {% endif
%}" />
value="{% if
setting in ["AUTOCONF_MODE", "SWARM_MODE", "KUBERNETES_MODE"] or global_config[setting]['method'] != 'ui' and global_config[setting]['method']
!= 'default' %}{{global_config[setting]['value']}}{% else %}no{% endif %}" />
<input type="hidden" name="{{setting}}" value="{% if
setting in ["AUTOCONF_MODE", "SWARM_MODE", "KUBERNETES_MODE"] or global_config[setting]['method'] != 'ui' and global_config[setting]['method']
!= 'default' %}{{global_config[setting]['value']}}{% else %}no{% endif %}" data-default-value="{% if