You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using a ButtonType in a form, the button does not have a specified id attribute by default. This results in the button being impossible to reference or submit in some cases where the id is required for JavaScript or CSS selectors.
How to reproduce
Create a Symfony Form: Define a form with a ButtonType without explicitly setting an id attribute.
Hello
I thought that since the fields of the forms came with their own id, it would be better to do the same for the form itself,
Note that when the attr option is enabled on a button, a form attribute is added to the field which is supposed to refer to the form by its id, but here the form ends up without.
Yes, we could just add the id with the options. But when I make a form.vars.id I see that a value exists. This means that in the form object there is an id that is defined but does not appear when the form rendered.
Re-reading the issue and looking at the code of our form themes I think what you request here should already be happening. Could it be that you use a custom form theme?
Symfony version(s) affected
5.4.31
Description
When using a ButtonType in a form, the button does not have a specified id attribute by default. This results in the button being impossible to reference or submit in some cases where the id is required for JavaScript or CSS selectors.
How to reproduce
Create a Symfony Form: Define a form with a ButtonType without explicitly setting an id attribute.
$builder->add('submit', ButtonType::class, [ 'label' => 'Submit', ]);
Attempt to Submit the Button..
Possible Solution
Add a default id attribute on form
Additional Context
No response
The text was updated successfully, but these errors were encountered: