-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Add extra data attributes for collections #5145
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
[Form] Add extra data attributes for collections #5145
Conversation
… element. Renamed prototype to collection prototype
{% if prototype is defined %} | ||
{% set attr = attr|merge({'data-prototype': form_row(prototype) }) %} | ||
{% set attr = attr|merge({'data-collection-prototype': form_row(prototype)}) %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a BC break as it changes the attribute name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, you're right. I didn't think it was because it's only in the template. What is the correct course of action from here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is not only in the template. It is also used by the JS code implemented by users with the existing attribute name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way to get a PR like this merged if it breaks backwards compatibility? IMO the break is pretty small. I could resubmit with the additions only but then the attributes would be inconsistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I think using data-prototype
as name would be better as it would keep the BC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that data-collection-prototype
would be a better name here, but I don't want to break BC. Can you please revert this and add a TODO-3.0.md file in the symfony root directory where you note that this attribute should be renamed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bschussek Just to be 100% clear.
- Keep the new attributes:
data-collection
,data-collection-add
&data-collection-delete
- Revert
data-collection-prototype
todata-prototype
- Add
data-collection
->data-collection-prototype
to TODO-3.0.md
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm against adding a TODO-3.0.md in the repository. Instead, create an issue on Github.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leevigraham exactly
@fabpot what do you think about it ? |
Closed in favour of #7713 |
PR for discussion.
Bug fix: no
Feature addition: yes
Backwards compatibility break: yes (user implementation of javascript)
Symfony2 tests pass: yes
I've added 3 extra data-* attributes to collections in twig templates and renamed the prototype attribute for easier js manipulation.
New attributes:
data-collection
: This is a collection and all children are form typesdata-collection-add
: Allow adding of new elementsdata-collection-delete
: Allow deletion of elements (new and existing)Renamed:
data-prototype
->data-collection-protoype
: Namespace prototype in the collection.This should make javascript integration much smoother.
Example js: