tags:

views:

396

answers:

3

I am using a Select element, in form

'country' =>new sfWidgetFormChoice(array('choices' => CountryPeer::getAllCountry())),

'city' =>new sfWidgetFormChoice(array('choices' => CityPeer::getAllCity())),

i want that city element to be disabled, at the first time when the page loads. and on selection of country the city element will be enabled.(it will be loaded through AJAX call)

A: 

If you already load the data of the second list via AJAX, why don't you disable and enable the second list via Javascript?

The disabling could be done either hardcoded in the template (with plain HTML) or done by Javascript (after document load).

For the enabling, use a callback method for the AJAX call (on the success event).

It would be could to know, how you actually do the AJAX call (jquery?).

Felix Kling
A: 

Well, most clean way is to learn "how to write your own widget" and actually write it. You can take a look at sfWidgetFormDate as a rough example.

develop7
+2  A: 

You can disable like this

$this->widgetSchema['country']->setAttribute('disabled', 'disabled');

metoikos
Yeah! This works the select option is disabled at first time when the form loads. thanks Metoikos!
Harish Kurup