symfony-collection
symfony-collection copied to clipboard
Update jquery.collection.js
Fixing label issue (#28)
Hello
Thank you for your contribution.
Quickly read the problem, and wondering if you checked this page?
https://symfony-collection.fuz.org/symfony3/troubleshoot/hide-form-labels
Yeah, but that's just hiding the label.
With my addition, it's now possible to actually use that label and show numbered "steps" or "items" if you will.
Nice. Will check this closer within a couple of hours.
Okay, so when adding fields, it works.
But when loading in such a collection it gets rendered by twig, currently i'm solving it with adding
{%- if name matches '/^\\d+$/' -%}
{%- set name = 'item ' ~ (name|number_format + 1) -%}
{%- endif -%}
But users need to add this to their templates if they want labels to be displayed properly.
And I think moving elements won't sort correctly those numbers. We may think of a better solution, like a selector to write position nbr somewhere.
Position is being stored in a hidden field, though.
Sure, but it may be more friendly to set a selector like span.position so you could use <label>Item #<span class="position"></span></label> to automatically fill Item #42 on your view without tricky hacks.
Yeah, but keep in mind it wouldn't always be "Item" either ;)