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

Refs #7974: Checkbox Multi Plain: Attribute werden eigentlich korrekt gesetzt, aber es geht nciht

parent 7f79cdac
Pipeline #2844 passed with stages
in 2 minutes and 37 seconds
...@@ -1104,7 +1104,7 @@ abstract class AbstractBuildForm { ...@@ -1104,7 +1104,7 @@ abstract class AbstractBuildForm {
} }
/** /**
* Create an array with standard elements for 'mode' (hidden, disabled, required) * Create an array with standard elements for 'mode' (hidden, disabled, required, readonly)
* and add 'form-element', 'value'. * and add 'form-element', 'value'.
* 'Generic Element Update': add via API_ELEMENT_UPDATE 'label' and 'note'. * 'Generic Element Update': add via API_ELEMENT_UPDATE 'label' and 'note'.
* All collected data as array - will be later converted to JSON. * All collected data as array - will be later converted to JSON.
...@@ -1113,11 +1113,13 @@ abstract class AbstractBuildForm { ...@@ -1113,11 +1113,13 @@ abstract class AbstractBuildForm {
* @param string|array $value * @param string|array $value
* @param array $formElement * @param array $formElement
* *
* @param int $optionIdx
* @param string $class
* @return array * @return array
* @throws \CodeException * @throws \CodeException
* @throws \UserFormException * @throws \UserFormException
*/ */
private function getFormElementForJson($htmlFormElementName, $value, array $formElement) { private function getFormElementForJson($htmlFormElementName, $value, array $formElement, $optionIdx = 0, $optionClass = '') {
$addClassRequired = array(); $addClassRequired = array();
$json = $this->getJsonFeMode($formElement[FE_MODE]); // disabled, required $json = $this->getJsonFeMode($formElement[FE_MODE]); // disabled, required
...@@ -1149,11 +1151,13 @@ abstract class AbstractBuildForm { ...@@ -1149,11 +1151,13 @@ abstract class AbstractBuildForm {
$addClassRequired = HelperFormElement::getRequiredPositionClass($formElement[F_FE_REQUIRED_POSITION]); $addClassRequired = HelperFormElement::getRequiredPositionClass($formElement[F_FE_REQUIRED_POSITION]);
} }
// Label
if (isset($formElement[FE_LABEL])) { if (isset($formElement[FE_LABEL])) {
$key = $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_LABEL; $key = $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_LABEL;
$json[API_ELEMENT_UPDATE][$key][API_ELEMENT_CONTENT] = $this->buildLabel($htmlFormElementName, $formElement[FE_LABEL], $addClassRequired[FE_LABEL] ?? ''); $json[API_ELEMENT_UPDATE][$key][API_ELEMENT_CONTENT] = $this->buildLabel($htmlFormElementName, $formElement[FE_LABEL], $addClassRequired[FE_LABEL] ?? '');
} }
// Note
if (isset($formElement[FE_NOTE])) { if (isset($formElement[FE_NOTE])) {
$key = $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_NOTE; $key = $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_NOTE;
if (!empty($addClassRequired[FE_NOTE])) { if (!empty($addClassRequired[FE_NOTE])) {
...@@ -1162,6 +1166,7 @@ abstract class AbstractBuildForm { ...@@ -1162,6 +1166,7 @@ abstract class AbstractBuildForm {
$json[API_ELEMENT_UPDATE][$key][API_ELEMENT_CONTENT] = $formElement[FE_NOTE]; $json[API_ELEMENT_UPDATE][$key][API_ELEMENT_CONTENT] = $formElement[FE_NOTE];
} }
// Input
if (isset($formElement[FE_TYPE])) { if (isset($formElement[FE_TYPE])) {
$key = $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_INPUT; $key = $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_INPUT;
...@@ -1174,15 +1179,26 @@ abstract class AbstractBuildForm { ...@@ -1174,15 +1179,26 @@ abstract class AbstractBuildForm {
if (!empty($formElement[FE_MODE_SQL])) { if (!empty($formElement[FE_MODE_SQL])) {
$class = is_numeric($formElement[FE_BS_INPUT_COLUMNS]) ? ('col-md-' . $formElement[FE_BS_INPUT_COLUMNS]) : $formElement[FE_BS_INPUT_COLUMNS]; $class = is_numeric($formElement[FE_BS_INPUT_COLUMNS]) ? ('col-md-' . $formElement[FE_BS_INPUT_COLUMNS]) : $formElement[FE_BS_INPUT_COLUMNS];
// $class = 'col-md-' . $formElement[FE_BS_INPUT_COLUMNS] . ' '; // $class = 'col-md-' . $formElement[FE_BS_INPUT_COLUMNS] . ' ';
$class .= ($formElement[FE_MODE] == FE_MODE_HIDDEN) ? ' hidden' : '';
$json[API_ELEMENT_UPDATE][$key][API_ELEMENT_ATTRIBUTE]['class'] = $class;
$json[API_ELEMENT_UPDATE][$key][API_ELEMENT_ATTRIBUTE]['required'] = ($formElement[FE_MODE] == 'required'); $json[API_ELEMENT_UPDATE][$key][API_ELEMENT_ATTRIBUTE]['required'] = ($formElement[FE_MODE] == 'required');
$json[API_ELEMENT_UPDATE][$key][API_ELEMENT_ATTRIBUTE]['hidden'] = $statusHidden; $json[API_ELEMENT_UPDATE][$key][API_ELEMENT_ATTRIBUTE]['hidden'] = $statusHidden;
$json[API_ELEMENT_UPDATE][$key][API_ELEMENT_ATTRIBUTE]['readonly'] = $json['disabled'] ? 'readonly' : 'false'; $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.
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;
}
$class .= ($formElement[FE_MODE] == FE_MODE_HIDDEN) ? ' hidden' : '';
$json[API_ELEMENT_UPDATE][$key][API_ELEMENT_ATTRIBUTE]['class'] = $class;
if ($pattern !== null) { if ($pattern !== null) {
$json[API_ELEMENT_UPDATE][$key][API_ELEMENT_ATTRIBUTE]['pattern'] = $pattern; $json[API_ELEMENT_UPDATE][$key][API_ELEMENT_ATTRIBUTE]['pattern'] = $pattern;
} }
} }
// #3647 // #3647
...@@ -2309,7 +2325,7 @@ abstract class AbstractBuildForm { ...@@ -2309,7 +2325,7 @@ abstract class AbstractBuildForm {
} }
$html .= $htmlElement . $br; $html .= $htmlElement . $br;
$json[] = $this->getFormElementForJson($htmlFormElementNameUniq, $jsonValue, $formElement); $json[] = $this->getFormElementForJson($htmlFormElementNameUniq, $jsonValue, $formElement, $ii, $checkboxClass);
} }
......
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