how to build a select-all Option for a dropdown list?

Discussion relating to version 1.3.x and 1.4.x

how to build a select-all Option for a dropdown list?

Postby dck_symfony » Thu Dec 17, 2009 10:31 pm

Hi,

im actually using a simple sfWidgetFormPropelChoice in a form to generate a select box with the options A,B,C.
(choosing A => submitting form => retrieving A)
(choosing B => submitting form => retrieving B)
(choosing C => submitting form => retrieving C)

Now i would like to create a select box with one additional option: D. So now i can choose between A,B,C,D before submitting the form.
The options A or B or C are just the same as before.
But how can i realize the following:
choosing D => submitting form => retrieving A,B,C

i need some kind a "select-all"-option, does somebody knows a solution or has a hint?
Last edited by dck_symfony on Thu Dec 17, 2009 10:54 pm, edited 1 time in total.
dck_symfony
Junior Member
 
Posts: 1
Joined: Thu Dec 17, 2009 10:17 pm

Re: how to build a select-all Option for a dropdown list?

Postby xplo » Thu Dec 17, 2009 11:22 pm

Code: Select all
//in the form
$this->getWidget('myWidget')->setOption('add_empty' => 'all');

//after the form is valided in the save method for exemple
if($this->getValue('myWidget') == null)
{
  //A+B+C + whatever you need to do
}
Last edited by xplo on Thu Dec 17, 2009 11:23 pm, edited 1 time in total.
xplo
Faithful Member
 
Posts: 593
Joined: Wed Sep 17, 2008 3:23 pm


Return to symfony 1.3 and 1.4

Who is online

Users browsing this forum: No registered users and 6 guests