whitebear
whitebear

Reputation: 12433

Making select box for Integer value form mapper

According this article.

Make select box for Integer value

I made this code

$formMapper
->add('length','choice',array('choices' => array(30,60,90,120))) 

But when I choose '90' ,'2' is recorded in Database.

I want to choose '90' and record in Database '90' as integer.

How can I do this?

Upvotes: 0

Views: 916

Answers (1)

redbirdo
redbirdo

Reputation: 4957

Try this:

$formMapper->add('length','choice',array('choices' => array(30 => 30, 60 => 60, 90 => 90, 120 => 120))) 

From the Symfony book, Choice Field Type:

The choices option is an array, where the array key is the item value and the array value is the item's label

Upvotes: 1

Related Questions