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

Configuration per data- attribute (inline)

Open pquerner opened this issue 6 years ago • 0 comments

Would it be possible to add inline configuration and initialization ? Something like

//...
->add('address', CollectionType::class, [
//...
                'attr'         => [
//...
                    'class' => 'my-selector',
                    'data-sfcollection' => 'true', //[1]
                    'data-sfcollection-min' => '1', //[2]
                    'data-sfcollection-<option>' => '<value>', //[3]
                ],
            ])
//...

[1] acts like

$(field.class.value).collection( //field.class.value equals the "class" attribute defined in your form (above)
                {
//...
                }
            );

[2,3] acts like

$(field.class.value).collection(
                {
<option>: <value>
                }
            );

Rendered solution would be

<input data-sfcollection='true' data-sfcollection-min='1'\>

JS-wise it would be enough to load the collection.js into current page and it would find automatically correct types by the data-sfcollection attribute.

pquerner avatar Sep 17 '17 16:09 pquerner