![profile picture](/public/style_images/master/profile/default_large.png)
[updated 24/11/2012] Dependent dropdown (library)
Posted 07 January 2013 - 13:19 PM
mirror, make sure your url is the right one. For example if you have index.php on the address bar then you need to include it also at the "url" like this,
$config = array(
'main_table' => '[color=#008800][size=2][background=rgb(248, 248, 248)]dd_goods[/background][/size][/color]',
'main_table_primary' => '[color=#008800][size=2][background=rgb(248, 248, 248)]goods_id[/background][/size][/color]',
'url' => base_url() . 'index.php/' . strtolower(__CLASS__) . '/' . strtolower(__FUNCTION__) . '/',
'ajax_loader' => base_url() . 'style/images/'. 'ajax-loader.gif'
);
strlower() might not needed in your case!
[/quote]
Thanks!
Now it works!
Posted 14 January 2013 - 12:19 PM
Posted 14 January 2013 - 12:21 PM
Posted 14 January 2013 - 12:27 PM
May be this /topic/364-answered-set-relation-and-add-new-button-to-quick-insert/ can help you
Posted 14 January 2013 - 12:27 PM
my parent dropdown is visible but inherited is still invisible
[/quote]
Can you explain it in more info?
Posted 15 January 2013 - 01:25 AM
I usually use javascript and AJAX in order to create that "dependent dropdown".
But I think you've just make everything simpler
![:)](/public/style_emoticons/default/smile.png)
Posted 17 January 2013 - 20:32 PM
![B)](/public/style_emoticons/default/cool.png)
![:D](/public/style_emoticons/default/biggrin.png)
Posted 22 January 2013 - 19:08 PM
I have been using this library, and running normally.
According to the example you gave on page one, what if the order is as follows:
1. city
2. state/province
3. country
the reason is to avoid user mistake during input.
a [b][u]city[/u][/b] must have a single [u][b]state[/b][/u] and a state must belong to one [b][u]country[/u][/b].
so when the user selects a city then automatically state/province and country of the city will be selected.
for example, if the user chose [b]Miami[/b] as a city, so it will be automatically selected [b]Florida[/b] as a state, and then [b] United Stated [/b][b]of America[/b] as a country.
Can it be solved by your library, or there may be slight modifications, please help.
thank you very much for your help Vic
Posted 22 January 2013 - 19:24 PM
In your case it could be a simple lookup on the database where for what the user selected as city shows[and makes read only automatically] the state and country.
In your case you just need one input, where on this library you must have at least two inputs before it show up the dependencies!
So, short answer, "no this library isn't for your case".
[quote name='gudjohnson' timestamp='1358881696' post='5202']
Hi, victor. well i think this is great library.
I have been using this library, and running normally.
According to the example you gave on page one, what if the order is as follows:
1. city
2. state/province
3. country
the reason is to avoid user mistake during input.
a [b][u]city[/u][/b] must have a single [u][b]state[/b][/u] and a state must belong to one [b][u]country[/u][/b].
so when the user selects a city then automatically state/province and country of the city will be selected.
for example, if the user chose [b]Miami[/b] as a city, so it will be automatically selected [b]Florida[/b] as a state, and then [b] United Stated [/b][b]of America[/b] as a country.
Can it be solved by your library, or there may be slight modifications, please help.
thank you very much for your help Vic
[/quote]
Posted 22 January 2013 - 19:32 PM
Question: But if there are some identical name of cities in one country (state) how does it must work ?
Posted 22 January 2013 - 19:35 PM
![:)](/public/style_emoticons/default/smile.png)
Posted 22 January 2013 - 19:35 PM
![;)](/public/style_emoticons/default/wink.png)
[quote name='victor' timestamp='1358883168' post='5204']
gudjohnson
Question: But if there are some identical name of cities in one country (state) how does it must work ?
[/quote]
Posted 23 January 2013 - 06:54 AM
[font="helvetica, arial, sans-serif"][color="#282828"]I'm facing a problem and the problem is, when i add a goods and select only country and state and then save it. after that when i edit this the city is automatically selected
![:mellow:](/public/style_emoticons/default/mellow.png)
[color=#282828][font=helvetica, arial, sans-serif]Thank you [/font][/color]
Posted 23 January 2013 - 07:15 AM
Posted 23 January 2013 - 08:30 AM
Posted 23 January 2013 - 08:40 AM
Posted 23 January 2013 - 08:45 AM
[php]$crud = new grocery_CRUD();
$crud->set_table('dd_goods');
$crud->set_relation('goods_country', 'dd_country', 'country_title');
$crud->set_relation('goods_state', 'dd_state', 'state_title');
$crud->set_relation('goods_city', 'dd_city', 'city_title');
$this->load->library('gc_dependent_select');
// settings
$fields = array(
// first field:
'goods_country' => array( // first dropdown name
'table_name' => 'dd_country', // table of country
'title' => 'country_title', // country title
'relate' => null // the first dropdown hasn't a relation
),
// second field
'goods_state' => array( // second dropdown name
'table_name' => 'dd_state', // table of state
'title' => 'state_title', // state title
'id_field' => 'state_id', // table of state: primary key
'relate' => 'country_ids', // table of state:
'data-placeholder' => 'select state' //dropdown's data-placeholder:
),
// third field. same settings
'goods_city' => array(
'table_name' => 'dd_city',
//'where' =>"post_code>'167'", // string. It's an optional parameter.
//'order_by'=>"state_title DESC", // string. It's an optional parameter.
'title' => 'id: {city_id} / city : {city_title}', // now you can use this format )))
'id_field' => 'city_id',
'relate' => 'state_ids',
'data-placeholder' => 'select city'
)
);
$config = array(
'main_table' => 'dd_goods',
'main_table_primary' => 'goods_id',
"url" => base_url()."/index.php/main/add_user/",
);
$categories = new gc_dependent_select($crud, $fields, $config);
// first method:
//$output = $categories->render();
// the second method:
$js = $categories->get_js();
$output = $crud->render();
$output->output.= $js;
$this->_example_output($output);[/php]
Posted 23 January 2013 - 09:25 AM
Posted 25 January 2013 - 21:46 PM
Regards!
![:)](/public/style_emoticons/default/smile.png)
Posted 27 January 2013 - 03:59 AM
I would like to consult you if you can not implement respecting the standard library tables, attached a picture so you can understand better.
Sorry for writing, is machine translation.
Thanks, Greetings.