English 中文(简体)
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 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





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签