Commit 56e6c420 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Refs #9691: dynamic update switch 'readonly' for 'checkbox plain multi' and 'radio plain multi': ok

parent c1ef0204
Pipeline #2857 passed with stages
in 3 minutes and 54 seconds
......@@ -1183,13 +1183,17 @@ abstract class AbstractBuildForm {
$json[API_ELEMENT_UPDATE][$key][API_ELEMENT_ATTRIBUTE]['hidden'] = $statusHidden;
$json[API_ELEMENT_UPDATE][$key][API_ELEMENT_ATTRIBUTE]['readonly'] = $json['disabled'] ? 'readonly' : 'false';
// Checkbox: Copy attributes to every checkbox:
// #7974 - nicht klar ob das hier wirklich sinnvoll ist: checkboxen gehen nicht auf readonly bei dynamic update - auch mit diesem IF nicht.
// Checkbox: Copy attributes to every checkbox (appreciated by screen reader):
if ($formElement[FE_TYPE] == FE_TYPE_CHECKBOX) {
$optionsKey = $formElement[FE_HTML_ID] . '-' . $optionIdx;
$json[API_ELEMENT_UPDATE][$optionsKey][API_ELEMENT_ATTRIBUTE] = $json[API_ELEMENT_UPDATE][$key][API_ELEMENT_ATTRIBUTE];
$json[API_ELEMENT_UPDATE][$optionsKey][API_ELEMENT_ATTRIBUTE]['data-disabled'] = $json['disabled'] ? 'yes' : 'no';
$json[API_ELEMENT_UPDATE][$optionsKey][API_ELEMENT_ATTRIBUTE]['class'] = $optionClass;
$optionsId = $formElement[FE_HTML_ID] . '-' . $optionIdx;
$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';
// Update label class (i.e.: 'qfq-disabled') of Checkbox/Radio (i.e. readonly on/off).
if (isset($formElement[FE_TMP_CLASS_OPTION])) {
$optionsLabelId = $this->getCheckboxRadioOptionId($formElement[FE_HTML_ID], $optionIdx, HTML_ID_EXTENSION_LABEL);
$json[API_ELEMENT_UPDATE][$optionsLabelId][API_ELEMENT_ATTRIBUTE]['class'] = $formElement[FE_TMP_CLASS_OPTION];
}
}
$class .= ($formElement[FE_MODE] == FE_MODE_HIDDEN) ? ' hidden' : '';
......@@ -1231,6 +1235,7 @@ abstract class AbstractBuildForm {
$key = $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_ROW;
$json[API_ELEMENT_UPDATE][$key][API_ELEMENT_ATTRIBUTE]['class'] = $class;
// $json[API_ELEMENT_UPDATE][$key][API_ELEMENT_ATTRIBUTE]['buggy'] = $class;
}
return $json;
......@@ -2275,7 +2280,7 @@ abstract class AbstractBuildForm {
$checkboxClass .= ' qfq-disabled'; // necessary for own style checkboxes to display them 'disabled'
}
// Used in getFormElementForJson() for dynamic update.
$formElement['_checkboxClass'] = $checkboxClass;
$formElement[FE_TMP_CLASS_OPTION] = $checkboxClass;
$br = '';
......@@ -2284,7 +2289,7 @@ abstract class AbstractBuildForm {
$jsonValue = false;
$attribute = $attributeBase;
$htmlFormElementNameUniq = HelperFormElement::prependFormElementNameCheckBoxMulti($htmlFormElementName, $ii, true);
$checkboxId = $this->checkboxRadioOptionId($formElement[FE_HTML_ID], $ii);
$checkboxId = $this->getCheckboxRadioOptionId($formElement[FE_HTML_ID], $ii);
$attribute .= Support::doAttribute('id', $checkboxId);
$attribute .= Support::doAttribute('name', $htmlFormElementNameUniq);
$attribute .= Support::doAttribute(ATTRIBUTE_DATA_REFERENCE, $formElement[FE_DATA_REFERENCE] . '-' . $ii);
......@@ -2314,7 +2319,7 @@ abstract class AbstractBuildForm {
// $htmlElement = Support::wrapTag('<label>', $htmlElement);
// }
$checkboxLabelId = $this->checkboxRadioOptionId($formElement[FE_HTML_ID], $ii, 'l');
$checkboxLabelId = $this->getCheckboxRadioOptionId($formElement[FE_HTML_ID], $ii, HTML_ID_EXTENSION_LABEL);
$htmlElement = Support::wrapTag("<label class='$checkboxClass' $attributeBaseLabel id='$checkboxLabelId'>", $htmlElement, true);
// control orientation
......@@ -2346,12 +2351,8 @@ abstract class AbstractBuildForm {
* @param string $type - ';' for label
* @return string
*/
private function checkboxRadioOptionId($base, $index, $type = '') {
if ($type != '') {
$type = '-' . $type;
}
private function getCheckboxRadioOptionId($base, $index, $type = '') {
return $base . '-' . $index . $type;
}
/**
* Submit extra (hidden) values by SIP.
......@@ -2558,11 +2559,15 @@ abstract class AbstractBuildForm {
// $radioOuterTag = ($orientation === ALIGN_HORIZONTAL) ? "label $attributeBaseLabel" : 'label';
$br = '';
// Used in getFormElementForJson() for dynamic update.
$formElement[FE_TMP_CLASS_OPTION] = $radioClass;
$attribute = $attributeBase;
if (isset($formElement[FE_AUTOFOCUS])) {
$attribute .= Support::doAttribute('autofocus', $formElement[FE_AUTOFOCUS]);
}
$jsonTmp = array();
for ($ii = 0; $ii < count($itemValue); $ii++) {
$jj++;
......@@ -2596,14 +2601,22 @@ abstract class AbstractBuildForm {
$wrapAttribute = Support::doAttribute('title', $formElement[FE_TOOLTIP]);
$wrapAttribute .= Support::doAttribute('class', $radioClass);
$htmlElement = Support::wrapTag("<label $wrapAttribute $attributeBaseLabel>", $htmlElement) . $br;
$radioLabelId = $this->getCheckboxRadioOptionId($formElement[FE_HTML_ID], $ii, HTML_ID_EXTENSION_LABEL);
$htmlElement = Support::wrapTag("<label $wrapAttribute $attributeBaseLabel id='$radioLabelId'>", $htmlElement) . $br;
$html .= $htmlElement;
$attribute = $attributeBase;
// Update label class (i.e.: 'qfq-disabled') of Checkbox/Radio (i.e. readonly on/off).
$optionsLabelId = $this->getCheckboxRadioOptionId($formElement[FE_HTML_ID], $ii, HTML_ID_EXTENSION_LABEL);
$jsonTmp[API_ELEMENT_UPDATE][$optionsLabelId][API_ELEMENT_ATTRIBUTE]['class'] = $formElement[FE_TMP_CLASS_OPTION];
}
$json = $this->getFormElementForJson($htmlFormElementName, $value, $formElement);
$json = array_merge($this->getFormElementForJson($htmlFormElementName, $value, $formElement));
$json[API_ELEMENT_UPDATE] = array_merge($json[API_ELEMENT_UPDATE], $jsonTmp[API_ELEMENT_UPDATE]);
return $html;
}
......
......@@ -1328,6 +1328,8 @@ const FE_ORDER_INTERVAL_DEFAULT = '10';
const FE_ORDER_COLUMN = 'orderColumn';
const FE_DND_TABLE = 'dndTable';
CONST FE_TMP_CLASS_OPTION = '_classOption';
const MODE_ENCODE = 'encode';
const MODE_DECODE = 'decode';
const MODE_NONE = 'none';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment