Skip to content

[Form] Unable to customize the attributes of all <option> generated by entity type #9289

@jean-pasqualini

Description

@jean-pasqualini

I currently use due to meet this challenge.

Eg.

        $builder->addEventListener(FormEvents::POST_SET_DATA, function(FormEvent $event)
        {
            $data = $event->getData();
            $form = $event->getForm();

            $formDisponibility = $form->get("disponibility");

            $choiceListOption  = $form->get("disponibility")->getConfig()->getOption("choice_list");

            $choices = $choiceListOption->getChoices();

            $views = $choiceListOption->getRemainingViews();

            foreach($choices as $key => $choice)
            {
                $view = $views[$key];

                $view->attr = array("data-day" => $choice->getDay());
            }

        });

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions