Commit e2ed910d authored by Carsten  Rose's avatar Carsten Rose
Browse files

Refs #9691: HTML ID for checkbox elements

parent 8477faeb
Pipeline #2853 passed with stages
in 3 minutes and 28 seconds
......@@ -2257,6 +2257,8 @@ abstract class AbstractBuildForm {
if ($formElement[FE_MODE] == FE_MODE_READONLY) {
$checkboxClass .= ' qfq-disabled'; // necessary for own style checkboxes to display them 'disabled'
}
// Used in getFormElementForJson() for dynamic update.
$formElement['_checkboxClass'] = $checkboxClass;
$br = '';
......@@ -2265,7 +2267,8 @@ abstract class AbstractBuildForm {
$jsonValue = false;
$attribute = $attributeBase;
$htmlFormElementNameUniq = HelperFormElement::prependFormElementNameCheckBoxMulti($htmlFormElementName, $ii, true);
$attribute .= Support::doAttribute('id', $formElement[FE_HTML_ID] . '-' . $ii);
$checkboxId = $this->checkboxRadioOptionId($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);
......@@ -2294,7 +2297,8 @@ abstract class AbstractBuildForm {
// $htmlElement = Support::wrapTag('<label>', $htmlElement);
// }
$htmlElement = Support::wrapTag("<label class='$checkboxClass' $attributeBaseLabel>", $htmlElement, true);
$checkboxLabelId = $this->checkboxRadioOptionId($formElement[FE_HTML_ID], $ii, 'l');
$htmlElement = Support::wrapTag("<label class='$checkboxClass' $attributeBaseLabel id='$checkboxLabelId'>", $htmlElement, true);
// control orientation
if ($formElement[FE_MAX_LENGTH] > 1) {
......@@ -2315,6 +2319,23 @@ abstract class AbstractBuildForm {
return $html;
}
/**
* Construct HTML ID for checkbox/radio option elements.
* Optional add $type.
* Example: $base='173-21612-1-0', $index='0', $type='l' >> '173-21612-1-0-0-l'
*
* @param $base
* @param $index
* @param string $type - ';' for label
* @return string
*/
private function checkboxRadioOptionId($base, $index, $type = '') {
if ($type != '') {
$type = '-' . $type;
}
return $base . '-' . $index . $type;
}
/**
* Submit extra (hidden) values by SIP.
*
......
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