Feature #60003

Add required-Attribute to f:form.password

Added by David Sporer over 6 years ago. Updated over 6 years ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
ViewHelpers
Target version:
-
Start date:
2014-06-30
Due date:
% Done:

0%

Estimated time:
Has patch:
No

Description

Currently the ViewHelper f:form.password doesn't support the required-Attribute.
According to W3C the required attribute is valid for input-elements of type "password": http://www.w3.org/TR/html-markup/input.password.html
Therefore I think TYPO3 Flow should allow the usage of the required Attribute.
Adding required as optional parameter like it's done for the TextfieldViewHelper should be appropriate, shouldn't it?

Current:

/**
     * Renders the password input field.
     *
     * @return string
     * @api
     */
    public function render() {
        $name = $this->getName();
        $this->registerFieldNameForFormTokenGeneration($name);

        $this->tag->addAttribute('type', 'password');
        $this->tag->addAttribute('name', $name);
        $this->tag->addAttribute('value', $this->getValue());

        $this->setErrorClassAttribute();

        return $this->tag->render();
    }

Should be:

/**
     * Renders the password input field.
     *
     * @param boolean $required If the field is required or not
     * @return string
     * @api
     */
    public function render($required = FALSE) {
        $name = $this->getName();
        $this->registerFieldNameForFormTokenGeneration($name);

        $this->tag->addAttribute('type', 'password');
        $this->tag->addAttribute('name', $name);
        $this->tag->addAttribute('value', $this->getValue());

        if ($required === TRUE) {
            $this->tag->addAttribute('required', 'required');
        }

        $this->setErrorClassAttribute();

        return $this->tag->render();
    }

I know that I can solve it by using the Textfield ViewHelper and specifying type="password" but it would be better if the password view helper also supports the required-Attribute.

#1

Updated by Bastian Waidelich over 6 years ago

Hi David,

this makes sense. In the meantime you can use the additionalAttributes argument:

<f:form.password property="password" additionalAttributes="{required: 'required')}" />

(not saying that it wouldn't make sense to add the "required" argument of course!)

Also available in: Atom PDF