Bug #71514
closedEXT:form - bring back "Show message in label"
100%
Description
The wizard allows the following setting "Show message in label". If set the validation message is rendered inside the label. This message is defined via message =
inside a validation rule. This will hide the hint for the user. It is not about hidding the message which is defined via error =
.
Right now this setting does nothing. We have to bring back the functionality.
Files
Updated by Carlos Meyer about 9 years ago
Hi *,
I tried to fix this issue with an extra property at the element model (showErrors).
In the FormBuilder I write a new method:
/** * Set the visibility of the mandatory message * and the validation error message * * @param Element $element * @return void */ protected function setVisibilityValidationMessages(Element $element) { $elementName = $element->getName(); $userConfiguredFormTyposcript = $this->configuration->getTypoScript(); $rulesTyposcript = isset($userConfiguredFormTyposcript['rules.']) ? $userConfiguredFormTyposcript['rules.'] : null; if (is_array($rulesTyposcript)) { $keys = TemplateService::sortedKeyList($rulesTyposcript); foreach ($keys as $key) { if ( (int)$key && strpos($key, '.') === false ) { $ruleArguments = $rulesTyposcript[$key . '.']; $fieldName = $this->formUtility->sanitizeNameAttribute($ruleArguments['element']); if ($fieldName == $elementName && $ruleArguments['showMessage'] == "1") { $element->setShowError(true); break; } } } } }
Call this method in 'reviveElement' line 361.
In the fluid view or in the compatibility layer we can ask than for this property and render the errors in the label or not.
The Problem is: We can have many validation messages beneath one element. So I think a clean approach is to add an submodel to 'elements'. That model holds the messages and the visibility.
An other approach is to add messages only if showMessages in TS is set to true, but I think this is a bit 'hacky'.
Any other ideas?
Thx
Updated by Gerrit Code Review almost 9 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/44946
Updated by Björn Jacob almost 9 years ago
Example form for testing:
enctype = multipart/form-data method = post prefix = tx_form confirmation = 1 postProcessor { 1 = mail 1 { recipientEmail = your@mail.com senderEmail = your@mail.com } } 10 = TEXTLINE 10 { type = text name = email placeholder = Email label { value = Email } } 20 = SUBMIT 20 { type = submit name = submit value = Submit } rules { 1 = required 1 { showMessage = 1 message = Required error = This field is required element = email } 2 = email 2 { showMessage = 0 message = (john.doe@domain.com) error = This is not a valid email address element = email } }
Updated by Gerrit Code Review almost 9 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/44946
Updated by Carlos Meyer almost 9 years ago
In my case it didn't work. Both messages are visible in label tag (see attached image).
Updated by Ralf Zimmermann almost 9 years ago
Yes but this is the error message not the mandatory message. "Show message in label" only affects the mandatory messages.
Updated by Ralf Zimmermann almost 9 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 5d98882623620d592c93fa778e2975ca3a8ffd9d.
Updated by Riccardo De Contardi about 7 years ago
- Status changed from Resolved to Closed