whitebear
whitebear

Reputation: 12423

make radio button with integer value by formbuilder

I am trying to make radio button via formbuilder.

I have integer column in entity.

It takes the number from 1-5.

At first I tried this.

$form = $this->createFormBuilder($myEntity)
    ->add('point',"choice",array(
        'data' => array(
            '1' => '1',
            '2' => '2',
            '3' => '3',
            '4' => '4',
            '5' => '5' 
        ),multiple => 'false'
    ))

It shows the list box instead of radio button. How can I make radio button?

Upvotes: 1

Views: 151

Answers (1)

M Khalid Junaid
M Khalid Junaid

Reputation: 64466

You need to use expanded => true in order to have radio buttons also add your choices array on choices option not in data option

$form = $this->createFormBuilder($myEntity)
             ->add( 'point', "choice", array(
                 'choices'  => array(
                     '1' => '1',
                     '2' => '2',
                     '3' => '3',
                     '4' => '4',
                     '5' => '5'
                 )
             ,'expanded' => true
));

Upvotes: 2

Related Questions