Home » CAKEPHP » Dynamic dropdown in cakephp 2.0 (Selectbox)
Dynamic dropdown and select box in cakephp 2.0
Dynamic dropdown and select box in cakephp 2.0

Dynamic dropdown in cakephp 2.0 (Selectbox)

Hello Friend, In this post i want to show you how to create dynamic dropdown in cakephp 2.x using ajax auto populating Select boxes, country state city selectbox in cakephp, cake selection box, Dependent dropdown in cakephp.

  • In this tutorials i want to demonstrate, How to create dynamic dropdown in cakephp. In cakephp this task become easy to develop dynamic dropdown country state city.
  • Cakephp is one of the most popular frameworks in the market to develope web application, cakephp development team provide wonderful functionality to make it possible.
  • Click here for what is cakephp.
  • Here I show to how to call ajax and load data dynamically without page load. Country state city is the best example for explaining this concept.
  • Here i use Cakephp version 2.5.6 for explaining this demo,  Also include download file to download whole demo free free free.

Database & Tables

  • First of all open mysql and create one database dropdowns this database contains three tables countries states and cities as below. state table has relation with country table and city table has relation with state table.

   Country State City tabel

  • Cakephp follow MVC(Model View Controller) pattern That’s why it’s contain three file Model, Controller, view.

More Information about cakephp click here.

  1. Controller File (app\Controller\CountriesController.php)
  • After controller file you must have to create three model file for your table as give bellow.

2) Country Model File(app\Model\Country.php)

3) State Model File (app\Model\State.php)

4) Cities Model file (app\Model\City.php)

  • After Model file you must be create view file for front view. View Folder should be contain all the view file with appropriate controller name.

5) View File (app\View\Countries\index.ctp)

  • You Must have to include jquery  file in defult.ctp. I also give Download link to download whole demo.




Live Demo Download

About Bhavin Shiroya

Check Also


What is cakephp?? for cakephp developers

  The CakePHP is a free, open-source, rapid development framework for PHP. It’s a foundational …

Get more stuff like this
in your inbox

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.