Skip to content

Using getBlockPrefix with null creates invalid html5 tag on form #19818

@ktwbc

Description

@ktwbc

There are use cases for returning null in a FormType definition with the call getBlockPrefix, for example to for a GET form to only use the form values in the resulting URL without a form name inside square brackets.

A typical case would be to simply add

 public function getBlockPrefix()
{
    return null;
}

to the formType.

However, this name is also being used to build the opening

tag when using
{{ form_start(form) }}
in the twig template. As a result of the null name, your form tag is created as:

<form name="" method="get">

The empty name "" is invalid HTML5 and will fail an HTML scan.

It would be preferable to simply leave the name off altogether in this case, i.e.

<form method="get">

if blockprefix is null.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions