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 » legacy support » symfony 1.2 » Dropdown onchange method
Dropdown onchange method [message #98613] Thu, 06 May 2010 11:49 Go to next message
krishna29bd
Messages: 4
Registered: May 2010
Junior Member
Hi,

I'm totally new in Symfony.I need some help regarding loading a dropdownlist depending on the selection of another dropdown list. Here is my sample code structure.

//---------------------------------------------------
class BaseDevnetPackageForm extends BaseFormPropel
{
public function setup()
{
$this->setWidgets(array(
'pkg_type' => new sfWidgetFormPropelChoice(array('model' => 'DevnetPackageType', 'add_empty' => true)),

'pkg_status' => new sfWidgetFormPropelChoice(array('model' => 'DevnetPackageStatus', 'add_empty' => true)),
));

$this->setValidators(array(
'pkg_type' => new sfValidatorPropelChoice(array('model' => 'DevnetPackageType', 'column' => 'ID', 'required' => false)),
'pkg_status' => new sfValidatorPropelChoice(array('model' => 'DevnetPackageStatus', 'column' => 'ID', 'required' => false))
));

$this->widgetSchema->setNameFormat('devnet_package[%s]');

$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

parent::setup();
}
//---------------------------------------------------
I could load above 2 dropdownlist from the database successfully. Now what i need is - 'pkg_status' will be loaded depending on the value selected on 'pkg_type'. How can i put onchange event to 'pkg_type' dropdownlist?
Please help me.

Thanks
Re: Dropdown onchange method [message #98861 is a reply to message #98613 ] Tue, 11 May 2010 12:17 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
Personally I would do this in raw jQuery. It's so easy to attach a change handler to an element, and then to repopulate another list via AJAX, that I've never learnt how to use the helpers.

Have I assumed correctly that you wish to repopulate (using ajax) without a complete page refresh?


Remember Palestine
Re: Dropdown onchange method [message #98907 is a reply to message #98861 ] Wed, 12 May 2010 05:07 Go to previous message
krishna29bd
Messages: 4
Registered: May 2010
Junior Member
Hi,

Finally i solved this problem. I used jquery to do this.
Thanks for your reply.
Previous Topic:Chane action template name
Next Topic:How to convert a SQL query to a Doctrine left join with subquery
Goto Forum:
  

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