Closed
Description
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.