From 0c4f517ebb0634848f7b6fb7f14488efcb082a44 Mon Sep 17 00:00:00 2001 From: Carsten Rose <carsten.rose@math.uzh.ch> Date: Sat, 10 Feb 2018 13:42:44 +0100 Subject: [PATCH] Feature 3470: Enter As Submit= on/off - implemented --- extension/Documentation/Manual.rst | 10 ++++++++-- extension/config.qfq.example.ini | 2 ++ extension/qfq/qfq/AbstractBuildForm.php | 5 +++-- extension/qfq/qfq/BuildFormBootstrap.php | 2 +- extension/qfq/qfq/Constants.php | 4 ++++ extension/qfq/qfq/QuickFormQuery.php | 1 + extension/qfq/qfq/store/Config.php | 1 + 7 files changed, 20 insertions(+), 5 deletions(-) diff --git a/extension/Documentation/Manual.rst b/extension/Documentation/Manual.rst index 4c2210ed4..25d8e50e8 100644 --- a/extension/Documentation/Manual.rst +++ b/extension/Documentation/Manual.rst @@ -395,6 +395,8 @@ config.qfq.ini | FORM_LANGUAGE_C_LABEL | | | | FORM_LANGUAGE_D_LABEL | | | +-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+ +| enterAsSubmit | enterAsSubmit = 1 | 0: off, 1: Pressing *enter* in a form means *save* and *close* | ++-----------------------------+-------------------------------------------------+----------------------------------------------------------------------------+ Example: *typo3conf/config.qfq.ini* @@ -1965,8 +1967,6 @@ Parameter +-----------------------------+--------+----------------------------------------------------------------------------------------------------------+ | classBody | string | HTML div with given class, surrounding all *FormElement*. | +-----------------------------+--------+----------------------------------------------------------------------------------------------------------+ -| submitButtonText | string | Show save button, with the <submitButtonText> at the bottom of the form. | -+-----------------------------+--------+----------------------------------------------------------------------------------------------------------+ | extraDeleteForm | string | Name of a form which specifies how to delete the primary record and optional slave records. | +-----------------------------+--------+----------------------------------------------------------------------------------------------------------+ | data-pattern-error | string | Pattern violation: Text for error message used for all FormElements of current form. | @@ -2006,6 +2006,10 @@ Parameter | mode | string | The value `readonly` will activate a global readonly mode of the form - the user can't change any data. | | | | See :ref:`form-mode-global` | +-----------------------------+--------+----------------------------------------------------------------------------------------------------------+ +| enterAsSubmit | digit | 0: off, 1: Pressing *enter* in a form means *save* and *close*. Takes default from `config.qfq.ini`_. | ++-----------------------------+--------+----------------------------------------------------------------------------------------------------------+ +| submitButtonText | string | Show a save button at the bottom of the form, with <submitButtonText> . See `submitButtonText`_. | ++-----------------------------+--------+----------------------------------------------------------------------------------------------------------+ | saveButtonActive | - | Make the 'save'-button active on *Form* load (instead of waiting for the first user change). | +-----------------------------+--------+----------------------------------------------------------------------------------------------------------+ | saveButtonText | string | Overwrite default from config.qfq.ini: SAVE_BUTTON_TEXT | @@ -2051,6 +2055,8 @@ Parameter * class = container-fluid * classBody = qfq-form-right +.. _submitButtonText: + submitButtonText '''''''''''''''' diff --git a/extension/config.qfq.example.ini b/extension/config.qfq.example.ini index 5f387692e..66d8723e2 100644 --- a/extension/config.qfq.example.ini +++ b/extension/config.qfq.example.ini @@ -124,3 +124,5 @@ WKHTMLTOPDF = /opt/wkhtmltox/bin/wkhtmltopdf ; FORM_LANGUAGE_D_ID = E.g. FORM_LANGUAGE_D_ID = 4 ; FORM_LANGUAGE_D_LABEL = E.g. FORM_LANGUAGE_D_ID = Chinese +; Pressing the 'enter' key is equal to save and close +; enterAsSubmit = 1 \ No newline at end of file diff --git a/extension/qfq/qfq/AbstractBuildForm.php b/extension/qfq/qfq/AbstractBuildForm.php index 0a863bcbc..b3c8cf118 100644 --- a/extension/qfq/qfq/AbstractBuildForm.php +++ b/extension/qfq/qfq/AbstractBuildForm.php @@ -321,7 +321,7 @@ abstract class AbstractBuildForm { public function getFormTag() { $md5 = ''; - $attribute = $this->getFormTagAtrributes(); + $attribute = $this->getFormTagAttributes(); $honeypot = $this->getHoneypotVars(); @@ -399,7 +399,7 @@ abstract class AbstractBuildForm { * * @return array */ - public function getFormTagAtrributes() { + public function getFormTagAttributes() { $attribute['id'] = $this->getFormId(); $attribute['method'] = 'post'; @@ -408,6 +408,7 @@ abstract class AbstractBuildForm { $attribute['accept-charset'] = 'UTF-8'; $attribute[FE_INPUT_AUTOCOMPLETE] = 'on'; $attribute['enctype'] = $this->getEncType(); + $attribute['data-disable-return-key-submit'] = $this->formSpec[F_ENTER_AS_SUBMIT] == '1' ? "false" : "true"; // attribute meaning is inverted return $attribute; } diff --git a/extension/qfq/qfq/BuildFormBootstrap.php b/extension/qfq/qfq/BuildFormBootstrap.php index ed62cf35d..11b3e8be7 100644 --- a/extension/qfq/qfq/BuildFormBootstrap.php +++ b/extension/qfq/qfq/BuildFormBootstrap.php @@ -495,7 +495,7 @@ class BuildFormBootstrap extends AbstractBuildForm { */ public function getFormTag() { - $attribute = $this->getFormTagAtrributes(); + $attribute = $this->getFormTagAttributes(); $attribute['class'] = 'form-horizontal'; $attribute['data-toggle'] = 'validator'; diff --git a/extension/qfq/qfq/Constants.php b/extension/qfq/qfq/Constants.php index 42e245a34..7b39743df 100644 --- a/extension/qfq/qfq/Constants.php +++ b/extension/qfq/qfq/Constants.php @@ -499,6 +499,8 @@ const SYSTEM_FORM_LANGUAGE_C_LABEL = 'FORM_LANGUAGE_C_LABEL'; const SYSTEM_FORM_LANGUAGE_D_ID = 'FORM_LANGUAGE_D_ID'; const SYSTEM_FORM_LANGUAGE_D_LABEL = 'FORM_LANGUAGE_D_LABEL'; +const SYSTEM_ENTER_AS_SUBMIT = 'enterAsSubmit'; + const DOCUMENTATION_QFQ = 'DOCUMENTATION_QFQ'; const DOCUMENTATION_QFQ_URL = 'https://docs.typo3.org/typo3cms/drafts/github/T3DocumentationStarter/Public-Info-053/Manual.html'; @@ -819,6 +821,8 @@ const F_NEW_BUTTON_TOOLTIP = 'newButtonTooltip'; const F_NEW_BUTTON_CLASS = 'newButtonClass'; const F_NEW_BUTTON_GLYPH_ICON = 'newButtonGlyphIcon'; +const F_ENTER_AS_SUBMIT = SYSTEM_ENTER_AS_SUBMIT; + // FORM_ELEMENT_STATI const FE_MODE_SHOW = 'show'; const FE_MODE_READONLY = 'readonly'; diff --git a/extension/qfq/qfq/QuickFormQuery.php b/extension/qfq/qfq/QuickFormQuery.php index 6be7d15a9..6cc122dd1 100644 --- a/extension/qfq/qfq/QuickFormQuery.php +++ b/extension/qfq/qfq/QuickFormQuery.php @@ -986,6 +986,7 @@ class QuickFormQuery { Support::setIfNotSet($formSpec, F_LDAP_USE_BIND_CREDENTIALS, ''); Support::setIfNotSet($formSpec, F_MODE, ''); Support::setIfNotSet($formSpec, F_DB_INDEX_DATA, $this->store->getVar(F_DB_INDEX_DATA, STORE_SYSTEM)); + Support::setIfNotSet($formSpec, F_ENTER_AS_SUBMIT, $this->store->getVar(SYSTEM_ENTER_AS_SUBMIT, STORE_SYSTEM)); // In case there is no F_MODE defined on the form, check if there is one in STORE_SIP. if ($formSpec[F_MODE] == '') { diff --git a/extension/qfq/qfq/store/Config.php b/extension/qfq/qfq/store/Config.php index 42c465197..8533cae02 100644 --- a/extension/qfq/qfq/store/Config.php +++ b/extension/qfq/qfq/store/Config.php @@ -206,6 +206,7 @@ class Config { Support::setIfNotSet($config, SYSTEM_RECORD_LOCK_TIMEOUT_SECONDS, SYSTEM_RECORD_LOCK_TIMEOUT_SECONDS_DEFAULT); Support::setIfNotSet($config, DOCUMENTATION_QFQ, DOCUMENTATION_QFQ_URL); + Support::setIfNotSet($config, SYSTEM_ENTER_AS_SUBMIT, 1); // Support::setIfNotSet($config, SYSTEM_FILL_STORE_SYSTEM_BY_SQL, SYSTEM_VAR_ADD_BY_SQL_DEFAULT); -- GitLab