8000 form collection label not correct ? · Issue #6607 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

form collection label not correct ? #6607

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

Closed
flip111 opened this issue May 23, 2016 · 6 comments
Closed

form collection label not correct ? #6607

flip111 opened this issue May 23, 2016 · 6 comments
Labels
Form hasPR A Pull Request has already been submitted for this issue. Waiting feedback

Comments

@flip111
Copy link
Contributor
flip111 commented May 23, 2016

My form prototype looks something like this

<data-prototype="<div class="form-group">
  <label class="col-sm-2 control-label required">__name__label__</label>
<div class="col-sm-10">

After replacement of __name__ it looks like: 0label__, 1label__, etc ..

i just followed the tutorial with the matching javascript

@flip111 flip111 changed the title javascript in Form Collections is problematic delete May 23, 2016
@flip111 flip111 changed the title delete form collection label not correct ? May 23, 2016
@xabbuh
Copy link
Member
xabbuh commented May 23, 2016

@HeahDude Would you mind having a look here?

Copy link
Contributor

Hi @flip111, it seems what you're experiencing with the label is expected.

In a collection type all sub types (including the prototype) use the same entry_options as options, and their label should often be set to an empty string or nullto prevent using their incrementing integer names as default or repeating the same label for all entries:

'entry_options' => array(
    'label' => false,
    // ...
),

When not set as above, the default label used by the prototype is the prototype_name option (default to __name__) suffixed by label__.

You could also used data-prototype="{{ form_widget(form.tags.vars.prototype)|e }} as in the note there, printing only the "widget" of the prototype should avoid the label issue.

@flip111
Copy link
Contributor Author
flip111 commented May 24, 2016

This shows up as the label for the CollectionType itself, seems like a bug then that the Entry label would affect the CollectionType label ??

For symfony i would suggest making the default label __label__ and not label__ because you also replace __name__ and not name__.

For symfony-docs i would suggest making a change in the javascript part that also does something with the label. Because right now when you just follow the docs you see this label__ and you think you did something wrong. __name__ is handled by this line:

var newForm = prototype.replace(/__name__/g, index);

The part you are pointing to says: To render it, make the following change to your template:. This is misleading because when you don't explicitly put it there there will be a protoype rendered anyway. Why not make it so that the code you need stays minimal and after that point to possibilities to customize it?

@HeahDude
Copy link
Contributor
HeahDude commented May 24, 2016

We cannot change the entry prototype default label as it would be a major BC break.

__name__ should be used to change the "name" attribute of the form, what happens here is that you can also change the prototype label using __name__label__.

I agree that some changes should be made on that part of the docs though, but I don' t see no bug here.

@flip111
Copy link
Contributor Author
flip111 commented May 24, 2016

The comment on the bug is a mistake on my part. So you suggest to replace __name__label__ first and then __name__ or first __name__ and then label__ ?

@HeahDude
Copy link
Contributor

__name__label__ first.

stoccc added a commit to stoccc/symfony-docs that referenced this issue Aug 11, 2017
stoccc added a commit to stoccc/symfony-docs that referenced this issue Aug 11, 2017
@xabbuh xabbuh added the hasPR A Pull Request has already been submitted for this issue. label Aug 16, 2017
xabbuh added a commit that referenced this issue Aug 29, 2017
This PR was merged into the 2.7 branch.

Discussion
----------

fix form collection label not correct

Fixes this #6607 in 2.7 branch

Commits
-------

dfa3891 fix form collection label not correct
@xabbuh xabbuh closed this as completed Aug 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Form hasPR A Pull Request has already been submitted for this issue. Waiting feedback
Projects
None yet
Development

No branches or pull requests

4 participants
0