Skip to content

[form] action attribute in html5 #13852

@jaytaph

Description

@jaytaph

In the current html5 draft, i've read the following:

The action and formaction content attributes, if specified, must have a value that is a valid non-empty URL potentially surrounded by spaces.

In the current implementation of the FormType follows the HTML4 specification, which allows it to be available and empty in order to post to the same URI (this is nicely documented in the formtype as well).

However, on HTML5 this is not allowed anymore, and afaict, an empty action should be completely removed from the output in order to do the same. Since we cannot really know if a user is creating a html4 or html5 site, maybe we should add an additional option to the form, that allows us to figure this out:

$form = $this->createFormBuilder(null, array(
    'method' => 'POST',
    'html5' => true,
));

renders: <form method="POST">

$form = $this->createFormBuilder(null, array(
    'method' => 'POST',
));

renders: <form method="POST" action="">

Since the DateTimeType also got a html5 option, it would be easier to have it directly in the formtype as well, as other types can automatically benefit from this information (like the rangeType, which could display <input type=range instead of some fallback in case we're not running html5-mode)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions