Project

General

Profile

Actions

Bug #71514

closed

EXT:form - bring back "Show message in label"

Added by Björn Jacob over 8 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Should have
Category:
Form Framework
Target version:
Start date:
2015-11-12
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

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

form.png (163 KB) form.png Carlos Meyer, 2015-11-26 16:34

Related issues 1 (0 open1 closed)

Has duplicate TYPO3 Core - Bug #71662: 7.6: Form ignores "Show message in label" settingClosed2015-11-18

Actions
Actions #1

Updated by Carlos Meyer over 8 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

Actions #2

Updated by Gerrit Code Review over 8 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

Actions #3

Updated by Björn Jacob over 8 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
    }
}

Actions #4

Updated by Gerrit Code Review over 8 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

Actions #5

Updated by Carlos Meyer over 8 years ago

In my case it didn't work. Both messages are visible in label tag (see attached image).

Actions #6

Updated by Ralf Zimmermann over 8 years ago

Yes but this is the error message not the mandatory message. "Show message in label" only affects the mandatory messages.

Actions #7

Updated by Björn Jacob over 8 years ago

  • Description updated (diff)
Actions #8

Updated by Carlos Meyer over 8 years ago

;-) Thx. Now I understand. Sorry.

Actions #9

Updated by Ralf Zimmermann over 8 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #10

Updated by Riccardo De Contardi over 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF