Zend 2 Dynamic Dependent Expansion with DB Call

For summarizing the question below, I'm trying to do http://demos.9lessons.info/sections_demo.php in Zend Framework 2 with a callback to the database.

For example, let's say that the list of countries had 50 values ​​(meaning 50 rows in my "country" table) and each country can have 1000 cities (50 x 1000 = 50,000 cities in the "cities" table).

Using Zend I can pull the list of countries with no problem, but how can I run my SQL to only select the thousands of cities I like in the second dropdown.

Am I doing this outside of the controller and the form and am doing it right in the edit.phtml page?

+3


source to share


1 answer


in the example you posted cities are not loaded by countries from the server side. Many countries and an empty list of cities are delivered from the server. When you select a country, the JavaScript code in the example requests the asynchronous server for the given cities in the country (it sends a request to ajax_city.php). So in this case, you need two actions in your controller. One of them is for creating a form and displaying it to the user, and the second is for queries in cities.



0


source







All Articles