Feature #60003

Add required-Attribute to f:form.password

Added by David Sporer about 1 year ago. Updated about 1 year ago.

Status:New Start date:2014-06-30
Priority:Should have Due date:
Assigned To:- % Done:

0%

Category:ViewHelpers
Target version:-
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.

History

#1 Updated by Bastian Waidelich about 1 year ago

Hi David,

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

1<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