Commit 6fa1fff3 authored by Carsten  Rose's avatar Carsten Rose
Browse files

B6467: 'element-update' now get's 'pattern=<pattern>|false' on element-update. Refs #6467

parent 4e2a07fc
Pipeline #1133 passed with stage
in 1 minute and 42 seconds
...@@ -997,14 +997,24 @@ abstract class AbstractBuildForm { ...@@ -997,14 +997,24 @@ abstract class AbstractBuildForm {
$json[API_ELEMENT_UPDATE][$key][API_ELEMENT_CONTENT] = $value; $json[API_ELEMENT_UPDATE][$key][API_ELEMENT_CONTENT] = $value;
} }
$statusHidden = ($formElement[FE_MODE] == 'hidden');
$pattern = null;
if ($formElement[FE_CHECK_PATTERN] != '') {
$pattern = $statusHidden ? false : $formElement[FE_CHECK_PATTERN];
}
// Check show/hide: only FE with FE_MODE_SQL given, might change. // Check show/hide: only FE with FE_MODE_SQL given, might change.
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' : ''; $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]['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'] = $formElement[FE_MODE] == 'hidden'; $json[API_ELEMENT_UPDATE][$key][API_ELEMENT_ATTRIBUTE]['hidden'] = $statusHidden;
if ($pattern !== null) {
$json[API_ELEMENT_UPDATE][$key][API_ELEMENT_ATTRIBUTE]['pattern'] = $pattern;
}
} }
// #3647 // #3647
...@@ -1014,8 +1024,12 @@ abstract class AbstractBuildForm { ...@@ -1014,8 +1024,12 @@ abstract class AbstractBuildForm {
//TODO #5016 - exception for FE_TYPE_CHECKBOX should be removed ASAP //TODO #5016 - exception for FE_TYPE_CHECKBOX should be removed ASAP
if ($formElement[FE_TYPE] != FE_TYPE_SELECT && $formElement[FE_TYPE] != FE_TYPE_UPLOAD && $formElement[FE_TYPE] != FE_TYPE_CHECKBOX) { if ($formElement[FE_TYPE] != FE_TYPE_SELECT && $formElement[FE_TYPE] != FE_TYPE_UPLOAD && $formElement[FE_TYPE] != FE_TYPE_CHECKBOX) {
$json[API_ELEMENT_UPDATE][$formElement[FE_HTML_ID]][API_ELEMENT_ATTRIBUTE]['value'] = $value; $json[API_ELEMENT_UPDATE][$formElement[FE_HTML_ID]][API_ELEMENT_ATTRIBUTE]['value'] = $value;
$json[API_ELEMENT_UPDATE][$formElement[FE_HTML_ID]][API_ELEMENT_ATTRIBUTE]['required'] = $formElement[FE_MODE] == 'required'; $json[API_ELEMENT_UPDATE][$formElement[FE_HTML_ID]][API_ELEMENT_ATTRIBUTE]['required'] = ($formElement[FE_MODE] == 'required');
$json[API_ELEMENT_UPDATE][$formElement[FE_HTML_ID]][API_ELEMENT_ATTRIBUTE]['hidden'] = $formElement[FE_MODE] == 'hidden'; $json[API_ELEMENT_UPDATE][$formElement[FE_HTML_ID]][API_ELEMENT_ATTRIBUTE]['hidden'] = $statusHidden;
if ($pattern !== null) {
$json[API_ELEMENT_UPDATE][$formElement[FE_HTML_ID]][API_ELEMENT_ATTRIBUTE]['pattern'] = $pattern;
}
} }
} }
...@@ -1277,8 +1291,8 @@ abstract class AbstractBuildForm { ...@@ -1277,8 +1291,8 @@ abstract class AbstractBuildForm {
$attribute .= $this->getAttributeList($formElement, [FE_INPUT_AUTOCOMPLETE, 'autofocus', 'placeholder']); $attribute .= $this->getAttributeList($formElement, [FE_INPUT_AUTOCOMPLETE, 'autofocus', 'placeholder']);
$pattern = Sanitize::getInputCheckPattern($formElement[FE_CHECK_TYPE], $formElement[FE_CHECK_PATTERN], $formElement[FE_DECIMAL_FORMAT], $sanitizeMessage); $formElement[FE_CHECK_PATTERN] = Sanitize::getInputCheckPattern($formElement[FE_CHECK_TYPE], $formElement[FE_CHECK_PATTERN], $formElement[FE_DECIMAL_FORMAT], $sanitizeMessage);
$attribute .= ($pattern === '') ? '' : 'pattern="' . $pattern . '" '; $attribute .= ($formElement[FE_CHECK_PATTERN] === '') ? '' : 'pattern="' . $formElement[FE_CHECK_PATTERN] . '" ';
if (empty($formElement[F_FE_DATA_PATTERN_ERROR])) { if (empty($formElement[F_FE_DATA_PATTERN_ERROR])) {
$formElement[F_FE_DATA_PATTERN_ERROR] = empty($sanitizeMessage) ? F_FE_DATA_PATTERN_ERROR_DEFAULT : $sanitizeMessage; $formElement[F_FE_DATA_PATTERN_ERROR] = empty($sanitizeMessage) ? F_FE_DATA_PATTERN_ERROR_DEFAULT : $sanitizeMessage;
} }
......
Supports Markdown
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