Skip to content
Snippets Groups Projects
Commit e92a6f2e authored by Carsten  Rose's avatar Carsten Rose
Browse files

Fixes dynamic updates for checkbox single plain & bootstrap.

parent a85f9245
No related branches found
No related tags found
1 merge request!221B9720 checkbox various setups
Pipeline #2974 failed
...@@ -253,9 +253,10 @@ class Checkbox { ...@@ -253,9 +253,10 @@ class Checkbox {
$htmlElement = '<input ' . $attribute . '>' . $valueShow; $htmlElement = '<input ' . $attribute . '>' . $valueShow;
$checkboxLabelId = HelperFormElement::getCheckboxRadioOptionId($formElement[FE_HTML_ID], $ii, HTML_ID_EXTENSION_LABEL); $labelAttribute = Support::doAttribute('title', $formElement[FE_TOOLTIP]);
$html .= Support::wrapTag("<label class='" . $formElement[FE_BUTTON_CLASS] . "$classActive' id=\"$checkboxLabelId\">", $labelAttribute .= Support::doAttribute('class', $formElement[FE_BUTTON_CLASS] . $classActive);
$htmlElement, true); $labelAttribute .= Support::doAttribute('id', HelperFormElement::getCheckboxRadioOptionId($formElement[FE_HTML_ID], $ii, HTML_ID_EXTENSION_LABEL));
$html .= Support::wrapTag("<label $labelAttribute>", $htmlElement, true);
$formElement[FE_TMP_CLASS_OPTION] = $labelBaseClass . $classActive; $formElement[FE_TMP_CLASS_OPTION] = $labelBaseClass . $classActive;
...@@ -411,7 +412,7 @@ class Checkbox { ...@@ -411,7 +412,7 @@ class Checkbox {
public function buildCheckboxSingle(array $formElement, $htmlFormElementName, $attribute, $value, array &$json, $mode = FORM_LOAD) { public function buildCheckboxSingle(array $formElement, $htmlFormElementName, $attribute, $value, array &$json, $mode = FORM_LOAD) {
// Bootstrap // Bootstrap
$attribute .= Support::doAttribute('id', $formElement[FE_HTML_ID]); $attribute .= Support::doAttribute('id', $formElement[FE_HTML_ID] . '-0');
$attribute .= Support::doAttribute('name', $htmlFormElementName); $attribute .= Support::doAttribute('name', $htmlFormElementName);
$attribute .= Support::doAttribute('value', $formElement[FE_CHECKBOX_CHECKED], false); $attribute .= Support::doAttribute('value', $formElement[FE_CHECKBOX_CHECKED], false);
$attribute .= Support::doAttribute('data-load', ($formElement[FE_DYNAMIC_UPDATE] === 'yes') ? 'data-load' : ''); $attribute .= Support::doAttribute('data-load', ($formElement[FE_DYNAMIC_UPDATE] === 'yes') ? 'data-load' : '');
...@@ -464,6 +465,7 @@ class Checkbox { ...@@ -464,6 +465,7 @@ class Checkbox {
if ($formElement[FE_BUTTON_CLASS] == '') { if ($formElement[FE_BUTTON_CLASS] == '') {
$formElement[FE_BUTTON_CLASS] = 'btn-default'; $formElement[FE_BUTTON_CLASS] = 'btn-default';
} }
$formElement[FE_BUTTON_CLASS] = 'btn ' . $formElement[FE_BUTTON_CLASS];
if ($formElement[FE_MODE] == FE_MODE_READONLY) { if ($formElement[FE_MODE] == FE_MODE_READONLY) {
$formElement[FE_BUTTON_CLASS] .= ' disabled'; $formElement[FE_BUTTON_CLASS] .= ' disabled';
...@@ -471,7 +473,7 @@ class Checkbox { ...@@ -471,7 +473,7 @@ class Checkbox {
$classActive = ''; $classActive = '';
if ($formElement[FE_CHECKBOX_CHECKED] === $value) { if ($formElement[FE_CHECKBOX_CHECKED] === $value) {
$classActive = ' active'; $formElement[FE_BUTTON_CLASS] .= ' active';
} }
$htmlHidden = HelperFormElement::buildNativeHidden($htmlFormElementName, $formElement[FE_CHECKBOX_UNCHECKED]); $htmlHidden = HelperFormElement::buildNativeHidden($htmlFormElementName, $formElement[FE_CHECKBOX_UNCHECKED]);
...@@ -486,10 +488,12 @@ class Checkbox { ...@@ -486,10 +488,12 @@ class Checkbox {
} }
$labelAttribute = Support::doAttribute('title', $formElement[FE_TOOLTIP]); $labelAttribute = Support::doAttribute('title', $formElement[FE_TOOLTIP]);
$labelAttribute .= Support::doAttribute('class', 'btn ' . $formElement[FE_BUTTON_CLASS] . $classActive); $labelAttribute .= Support::doAttribute('class', $formElement[FE_BUTTON_CLASS]);
$labelAttribute .= Support::doAttribute('id', HelperFormElement::getCheckboxRadioOptionId($formElement[FE_HTML_ID], 0, HTML_ID_EXTENSION_LABEL));
$html .= Support::wrapTag("<label $labelAttribute>", $htmlElement, true); $html .= Support::wrapTag("<label $labelAttribute>", $htmlElement, true);
$html = Support::wrapTag('<div class="btn-group" data-toggle="buttons">', $html); $html = Support::wrapTag('<div class="btn-group" data-toggle="buttons">', $html);
$formElement[FE_TMP_CLASS_OPTION] = $formElement[FE_BUTTON_CLASS];
$json = $this->getFormElementForJsonCheckbox($htmlFormElementName, $valueJson, $formElement); $json = $this->getFormElementForJsonCheckbox($htmlFormElementName, $valueJson, $formElement);
return $html; return $html;
...@@ -567,6 +571,8 @@ class Checkbox { ...@@ -567,6 +571,8 @@ class Checkbox {
$json[API_ELEMENT_UPDATE][$optionsId][API_ELEMENT_ATTRIBUTE] = $json[API_ELEMENT_UPDATE][$key][API_ELEMENT_ATTRIBUTE]; $json[API_ELEMENT_UPDATE][$optionsId][API_ELEMENT_ATTRIBUTE] = $json[API_ELEMENT_UPDATE][$key][API_ELEMENT_ATTRIBUTE];
$json[API_ELEMENT_UPDATE][$optionsId][API_ELEMENT_ATTRIBUTE]['data-disabled'] = $json['disabled'] ? 'yes' : 'no'; $json[API_ELEMENT_UPDATE][$optionsId][API_ELEMENT_ATTRIBUTE]['data-disabled'] = $json['disabled'] ? 'yes' : 'no';
$json[API_ELEMENT_UPDATE][$optionsId][API_ELEMENT_ATTRIBUTE]['data-required'] = $json['required'] ? 'yes' : 'no'; $json[API_ELEMENT_UPDATE][$optionsId][API_ELEMENT_ATTRIBUTE]['data-required'] = $json['required'] ? 'yes' : 'no';
$json[API_ELEMENT_UPDATE][$optionsId][API_ELEMENT_ATTRIBUTE]['disabled'] = $json['disabled'] ? 'disabled' : 'false';
$json[API_ELEMENT_UPDATE][$optionsId][API_ELEMENT_ATTRIBUTE]['required'] = $json['required'] ? 'required' : 'false';
// Update label class (i.e.: 'qfq-disabled') of Checkbox/Radio (i.e. readonly on/off). // Update label class (i.e.: 'qfq-disabled') of Checkbox/Radio (i.e. readonly on/off).
if (isset($formElement[FE_TMP_CLASS_OPTION])) { if (isset($formElement[FE_TMP_CLASS_OPTION])) {
...@@ -633,13 +639,17 @@ class Checkbox { ...@@ -633,13 +639,17 @@ class Checkbox {
$labelAttribute = Support::doAttribute('title', $formElement[FE_TOOLTIP]); $labelAttribute = Support::doAttribute('title', $formElement[FE_TOOLTIP]);
$class = 'checkbox'; $formElement[FE_BUTTON_CLASS] = 'checkbox';
if ($formElement[FE_MODE] == FE_MODE_READONLY) { if ($formElement[FE_MODE] == FE_MODE_READONLY) {
$class .= ' qfq-disabled'; // necessary for own style checkboxes to display them 'disabled' $formElement[FE_BUTTON_CLASS] .= ' qfq-disabled'; // necessary for own style checkboxes to display them 'disabled'
} }
$html = Support::wrapTag("<label class='$class' $labelAttribute>", $html, true); $formElement[FE_TMP_CLASS_OPTION] = $formElement[FE_BUTTON_CLASS];
// $html = Support::wrapTag("<div class='checkbox'>", $html, true); $labelAttribute = Support::doAttribute('title', $formElement[FE_TOOLTIP]);
$labelAttribute .= Support::doAttribute('class', $formElement[FE_BUTTON_CLASS]);
$labelAttribute .= Support::doAttribute('id', HelperFormElement::getCheckboxRadioOptionId($formElement[FE_HTML_ID], 0, HTML_ID_EXTENSION_LABEL));
$html = Support::wrapTag("<label $labelAttribute>", $html, true);
$json = $this->getFormElementForJsonCheckBox($htmlFormElementName, $valueJson, $formElement); $json = $this->getFormElementForJsonCheckBox($htmlFormElementName, $valueJson, $formElement);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment