0

Hello friends a pleasure to be around here, I'm new to this framework and I have a few doubts about how to make dependent dropdown, for example, I have a list of countries and select a country to show me their states hope I can help from already thank you very much.

baxi2990
  • 13
  • 4
  • You definitely can do that with JavaScript chain. Something like $dropdown->js('onchange',$other_dropdown->js()->reload(null,array('parent_id'=>$dropdown->js()->val()))); – DarkSide Apr 15 '13 at 23:07
  • But I guess there should be some simpler way to accomplish this which I can't remember right now (too late night here). – DarkSide Apr 15 '13 at 23:09
  • BTW, is this your question too: http://stackoverflow.com/questions/15994508/how-to-set-a-filter-on-a-field-referencing-a-model-in-atk4 – DarkSide Apr 15 '13 at 23:22

2 Answers2

1

Here is a demo of what you're looking for:

http://demo39.agiletoolkit.org/demo.html?t=20

romaninsh
  • 10,606
  • 4
  • 50
  • 70
0

Could it be that above example (http://demo39.agiletoolkit.org/demo.html?t=20) only works when the arrays have numbers for their dropdown values? ie:

$country_list=array(1=>'Country1', 2=>'Country2')
$state_list=array(1=>array('st1','st2'),2=>array('st3')

night it be the demo will not work when using:

$country_list=array('COUNTRY1'=>'Country1','COUNTRY2'=>'Country2')
$state_list=array('COUNTRY1'=>array('ST1'=>'st1','ST2'=>'st2'),'COUNTRY2'=>array('ST3'=>'st3')

with the second setup I get an error at form submit time saying:

Value 'ST3' is not one of the offered values

or am I doing something else wrong? should I (not) use stickyGET for instance?

gsteenss
  • 68
  • 5