symfony-collection icon indicating copy to clipboard operation
symfony-collection copied to clipboard

Update jquery.collection.js

Open Coffee2CodeNL opened this issue 8 years ago • 8 comments
trafficstars

Fixing label issue (#28)

Coffee2CodeNL avatar Aug 01 '17 16:08 Coffee2CodeNL

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

ninsuo avatar Aug 01 '17 16:08 ninsuo

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.

Coffee2CodeNL avatar Aug 01 '17 16:08 Coffee2CodeNL

Nice. Will check this closer within a couple of hours.

ninsuo avatar Aug 01 '17 16:08 ninsuo

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.

Coffee2CodeNL avatar Aug 01 '17 18:08 Coffee2CodeNL

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.

ninsuo avatar Aug 01 '17 18:08 ninsuo

Position is being stored in a hidden field, though.

Coffee2CodeNL avatar Aug 01 '17 18:08 Coffee2CodeNL

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.

ninsuo avatar Aug 01 '17 19:08 ninsuo

Yeah, but keep in mind it wouldn't always be "Item" either ;)

Coffee2CodeNL avatar Aug 01 '17 19:08 Coffee2CodeNL