This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » support » General discussion » Adding an empty choice while passing a Doctrine object to sfWidgetFormChoice
Adding an empty choice while passing a Doctrine object to sfWidgetFormChoice [message #103417] Mon, 02 August 2010 14:48 Go to next message
sharmil  is currently offline sharmil
Messages: 6
Registered: August 2010
Location: Mumbai, India
Junior Member
Hello,

I am trying to create a form field 'City' using sfForms. While passing a Doctrine object from my 'city' table to the 'choices' option works fine, I would like to have the first option to be something like '-Select City-'. How do I achieve this?

My current form code for the city field is as follows:

	$this->form->setWidgets(array(
		  'city' => new sfWidgetFormChoice(array('label'=> 'City','choices' => Doctrine::getTable('City')->getCityListByCountry($country_id)))
	)); 
Re: Adding an empty choice while passing a Doctrine object to sfWidgetFormChoice [message #103418 is a reply to message #103417 ] Mon, 02 August 2010 14:59 Go to previous messageGo to next message
xplo  is currently offline xplo
Messages: 428
Registered: September 2008
Faithful Member
you should use sfWidgetFormDoctrineChoice instead of sfWidgetFormChoice then you ll set the 'add_empty' option to '-Select City'
Re: Adding an empty choice while passing a Doctrine object to sfWidgetFormChoice [message #103422 is a reply to message #103418 ] Mon, 02 August 2010 15:28 Go to previous message
sharmil  is currently offline sharmil
Messages: 6
Registered: August 2010
Location: Mumbai, India
Junior Member
Thanks! That worked perfectly.
Previous Topic:Actions Class Corresponding To Global Layout (layout.php)
Next Topic:Propel 1.5 is awesome - Try it asap.
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software