setProperty($propertyName) ->setLabel($label) ->setTemplatePath('@LcSov/tabler/crud/field/collection.html.twig') ->setFormType(CollectionType::class) ->addCssClass('field-collection') ->addJsFiles('bundles/lcsov/js/form-type-collection-array.js') ->setFormTypeOption('allow_add', true) ->setFormTypeOption('allow_delete', true) ->setFormTypeOption('entry_options', array('label' => false)) ->setFormTypeOption('attr', array('class' => 'field-collection-group')) //Fixe le bug easyadmin lors de la gestion d'un champ de type array, laisser a false pour une entité ->setFormTypeOption('row_attr', array('data-reindex-key' => true)); } public function allowAdd(bool $allow = true): self { $this->setCustomOption(self::OPTION_ALLOW_ADD, $allow); return $this; } public function allowDelete(bool $allow = true): self { $this->setCustomOption(self::OPTION_ALLOW_DELETE, $allow); return $this; } /** * Set this option to TRUE if the collection items are complex form types * composed of several form fields (EasyAdmin applies a special rendering to make them look better). */ public function setEntryIsComplex(bool $isComplex): self { $this->setCustomOption(self::OPTION_ENTRY_IS_COMPLEX, $isComplex); return $this; } public function setEntryType(string $formTypeFqcn): self { $this->setCustomOption(self::OPTION_ENTRY_TYPE, $formTypeFqcn); return $this; } public function showEntryLabel(bool $showLabel = true): self { $this->setCustomOption(self::OPTION_SHOW_ENTRY_LABEL, $showLabel); return $this; } }