How to dynamically load dropdown options in Symfony without JavaScript?

I’m working with Symfony forms and need help with dependent dropdowns. Here’s my current form setup:

'country' => new sfWidgetFormChoice(array('choices' => CountryPeer::getCountryList())),
'region' => new sfWidgetFormChoice(array('choices' => RegionPeer::getRegionList())),

What I want to achieve is when a user selects a country from the first dropdown (for example USA), the second dropdown should automatically show only the regions that belong to that selected country. The important thing is I need to handle this on the server side without using any JavaScript solutions. How can I make these dropdowns work together where the second one depends on the first selection?

just submit the form after picking a country, itll reload the regions automatically based on your selection. you could use onChange event for the country dropdown to handle this. then in your controller, filter the regions based on the selected country_id.

interesting! are you thinking about using symfony’s form events? you could listen for pre_set_data or pre_submit to update the region choices based on the country selection. what symfony version are you using?