开发者

To populate select options at backend using Symfony?

the symfony form is, 'nation' =>new sfWidgetFormChoice(array('choices' => NationPeer::getAllNation())), 'township' =>new sfWidgetFormChoice(array('choices' => TownshipPeer::getAllTownship())), On selecting the nation (like India) it should开发者_StackOverflow populate township(with the township within India). I Dont want to use Javascripts!


Unfortunately a web page cannot react to a client action unless JavaScript is used.


If I understand it correctly you want to change the second sfWidgetFormChoice depending on the selection of the first sfWidgetFormChoice. On the loading of the page you can prerender the current selected value for the second form already, but when you change the value of the first form you want to change the value of the second form too, right?

I'm sorry, but one way or another, you must depend on Javascript for this. With Symfony you can use the AJAX helpers to solve this problem and not be bothered by writing to many Javascript by yourself. You can use the 'observe_field' function to change the second Form to your new value. The trick is to rerender the second Widget with a different value every time.

See this page for more information: http://www.symfony-project.org/book/1_2/11-Ajax-Integration#chapter_11_sub_ajax_driven_forms

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜