New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend ChoiceType children options #27340

Closed
jbdelhommeau opened this Issue May 22, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@jbdelhommeau

jbdelhommeau commented May 22, 2018

Description
New feature request has start with the blog post : Form field help. It's a great post that explain how to extend a form to add a custom option help to show help message. I asked myself how to add this help message in an item choice of choiceType form. I wanted to make that like a choice_attr and callable function. But I cant. I fact ChoiceType create his children fields (Radio or Checkbox) with ChoiceView class and we can't add your custom options.

In resume we can't extend choice_options like this:

        $builder
            ->add('dilem', ChoiceType::class, [
                'choices'     => [
                    'foo' => false,
                    'bar' => true,
                ],
                'choice_options' => function ($value, $key, $index) {
                    if ($value) {
                        return ['help' => 'My Help message'];
                    }
                },
                'expanded'      => true,
                'multiple'      => false,
            ]) ;

I want to modify the code and create the pull request but can someone can accompany me to do it properly ?

@xabbuh

This comment has been minimized.

Member

xabbuh commented Sep 23, 2018

I think this is the same feature request as #18318. So I am closing here as a duplicate.

@xabbuh xabbuh closed this Sep 23, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment