8000 Option to disable rendering name attribute to submit button · Issue #28964 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content 8000
Option to disable rendering name attribute to submit button #28964
Closed
@Ferikl

Description

@Ferikl

Description
Add Possibility to not render name attribute to submit button (SubmitType).

Example

I want to create simple Search Form like this:

use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;

$form = $formFactory->createNamedBuilder(null, FormType::class, null, ['csrf_protection' => false])
            ->setMethod('GET')
            ->add('tag', TextType::class, ['label' => 'Tag name'])
            ->add('Search By Tags', SubmitType::class)

            ->getForm()
        ;

When I render my Form in template

{{ form_start(form) }}
{{ form_errors(form) }}
{{ form_end(form) }}

I can see:

<button type="submit" id="Search By Tags" name="Search By Tags" class="btn-secondary btn">Search By Tags</button>

But I dont want to have &Search+By+Tags= in my URL after form submit and Error with message:

ERROR This form should not contain extra fields.

So my suggestion is to add some param/option to SubmitType::class or whatever to NOT render name="Search By Tags" attribute.

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

      0