Commit 7d895a43 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Fixes #7594: FE.type=extra: don't name it 'type' or 'id' or 'L' - more...

Fixes #7594: FE.type=extra: don't name it 'type' or 'id' or 'L' - more detailed error message and an explanation in Manual.rst.
parent 9a5889c3
Pipeline #1277 passed with stage
in 1 minute and 51 seconds
......@@ -3055,11 +3055,13 @@ Type: datetime
Type: extra
^^^^^^^^^^^
* The element behaves like, and can be used as, a HTML hidden input element - with the difference & advantage, that the
element never leaves the server and therefore can't be manipulated by a user.
* The following names are reserved and can't be used to name 'extra' FormElements: 'id', 'type', 'L'.
* The element is not transferred to the the browser.
* The element behaves like, and can be used as, a HTML hidden input element - with the advantage that the element never
leaves the server and therefore can't be manipulated by a user.
* The element can be used to define / precalculate values for a column, which do not already exist as a native *FormElement*.
* The element can be used to define / pre calculate values for a column, which do not already exist as a native *FormElement*.
* The element is build / computed on form load and saved alongside with the SIP parameter of the current form.
* The element is not recalculated during save - it's stored during 'Form Load' inside the current form SIP handle.
* Access the value without specifying any store (default store priority is sufficient).
.. _`input-text`:
......
......@@ -210,6 +210,7 @@ const ERROR_INVALID_DATE = 1086;
// Subrecord
const ERROR_SUBRECORD_MISSING_COLUMN_ID = 1100;
const ERROR_SUBRECORD_DETAIL_COLUMN_NOT_FOUND = 'Column not found in primary record or current row';
// Store
const ERROR_STORE_VALUE_ALREADY_CODPIED = 1200;
const ERROR_STORE_KEY_EXIST = 1201;
......@@ -332,6 +333,10 @@ const ERROR_THUMBNAIL_RENDER = 2600;
// Drag and Drop
const ERROR_DND_EMPTY_REORDER_SQL = 2700;
// Form
const ERROR_FORM_RESERVED_NAME = 2800;
//
// Store Names: Identifier
//
......
......@@ -237,6 +237,13 @@ class FillStoreForm {
if ($formElement[FE_TYPE] === FE_TYPE_EXTRA) {
// Extra elements will be transferred by SIP
if (!isset($sipValues[$formElement[FE_NAME]])) {
# Check for reserved names.
if ($formElement[FE_NAME] == CLIENT_PAGE_ID || $formElement[FE_NAME] == CLIENT_PAGE_TYPE || $formElement[FE_NAME] == CLIENT_PAGE_LANGUAGE) {
throw new UserFormException(
json_encode(
[ERROR_MESSAGE_TO_USER => 'Reserved name "' . $formElement[FE_NAME] . '" in FormElement.',
ERROR_MESSAGE_SUPPORT => 'FE_TYPE="extra" should not use ' . CLIENT_PAGE_ID . ',' . CLIENT_PAGE_TYPE . ',' . CLIENT_PAGE_LANGUAGE]), ERROR_FORM_RESERVED_NAME);
}
throw new CodeException("Missing the " . FE_TYPE_EXTRA . " field '" . $formElement[FE_NAME] . "' in SIP.", ERROR_MISSING_HIDDEN_FIELD_IN_SIP);
}
......@@ -376,7 +383,7 @@ class FillStoreForm {
*/
public function doDateTime(array &$formElement, $value) {
$regexp = Support::dateTimeRegexp($formElement[FE_TYPE], $formElement[FE_DATE_FORMAT], $formElement[FE_TIME_IS_OPTIONAL]??"");
$regexp = Support::dateTimeRegexp($formElement[FE_TYPE], $formElement[FE_DATE_FORMAT], $formElement[FE_TIME_IS_OPTIONAL] ?? "");
if (1 !== preg_match('/' . $regexp . '/', $value, $matches)) {
$placeholder = Support::getDateTimePlaceholder($formElement);
......
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