Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove select required attribute #4498

Closed
wants to merge 1 commit into from
Closed

Conversation

apapacy
Copy link

@apapacy apapacy commented May 27, 2017

I am targeting this branch, because it is patch.

Closes #4022, #4486

Changelog

### Removed
Attribute 'required' from HTML element select in Resources/views/Form/Type/sonata_type_model_autocomplete.html.twig

### Fixed
Error on save form with autocomplete form field ('sonata_type_model_autocomplete') where required is set to 'true'

### Security
Input field in 'sonata_type_model_autocomplete' already  have attribute 'required'

Subject

Fix problem with required autocomplete field on save from.

@greg0ire
Copy link
Contributor

Please associate your meta.ua email address with your Github account, or change the email in your commits to an address already associated with it.

@@ -19,7 +19,6 @@ file that was distributed with this source code.
<select id="{{ id }}_autocomplete_input_v4" data-sonata-select2="false"
{%- if read_only is defined and read_only %} readonly="readonly"{% endif -%}
{%- if disabled %} disabled="disabled"{% endif -%}
{%- if required %} required="required"{% endif %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This select does not have a name attribute. I think the right fix might be to specify one.

Copy link
Author

@apapacy apapacy May 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name attribute present in input type='hidden' element.
https://github.com/sonata-project/SonataAdminBundle/blob/3.x/Resources/views/Form/Type/sonata_type_model_autocomplete.html.twig#L32

If you define name attribute for select element - then this value will be sent to the server that is undesirable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't select2 supposed to remove it just before submit? Not sure why we are building the hidden fields ourselves either.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure they are even supposed to be there anymore : https://select2.github.io/announcements-4.0.html#hidden-input

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the hidden input element must be deleted! In this regard, Im close this pull request.

@apapacy apapacy closed this May 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Required sonata_type_model_autocomplete causing "An invalid form control with name='' is not focusable"
3 participants