⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

[updated 24/11/2012] Dependent dropdown (library)



mirr0r
  • profile picture
  • Member

Posted 07 January 2013 - 13:19 PM

[quote name='David Oster' timestamp='1357562029' post='5009']
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!

zrmba
  • profile picture
  • Member

Posted 14 January 2013 - 12:19 PM

Hi victor, thank you for the great job you are doing. But is it not possible to extend that library so that it contain the quick add functionality you explaned somewhere too?

Tousif Khan
  • profile picture
  • Member

Posted 14 January 2013 - 12:21 PM

my parent dropdown is visible but inherited is still invisible

victor
  • profile picture
  • Member

Posted 14 January 2013 - 12:27 PM

Hi zrmba and welcome to the forum.
May be this /topic/364-answered-set-relation-and-add-new-button-to-quick-insert/ can help you

victor
  • profile picture
  • Member

Posted 14 January 2013 - 12:27 PM

[quote name='Tousif Khan' timestamp='1358166110' post='5075']
my parent dropdown is visible but inherited is still invisible
[/quote]
Can you explain it in more info?

goFrendiAsgard
  • profile picture
  • Member

Posted 15 January 2013 - 01:25 AM

Hi Victor, thank you for making this library.
I usually use javascript and AJAX in order to create that "dependent dropdown".
But I think you've just make everything simpler :)

victor
  • profile picture
  • Member

Posted 17 January 2013 - 20:32 PM

As I see many peoples like this library B) :D

gudjohnson
  • profile picture
  • Member

Posted 22 January 2013 - 19:08 PM

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

davidoster
  • profile picture
  • Member

Posted 22 January 2013 - 19:24 PM

gudjohnson what you are describing is not a dependency problem the way this library works for.
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]

victor
  • profile picture
  • Member

Posted 22 January 2013 - 19:32 PM

gudjohnson
Question: But if there are some identical name of cities in one country (state) how does it must work ?

victor
  • profile picture
  • Member

Posted 22 January 2013 - 19:35 PM

You can use my library as example and make the same library for your problem :)

davidoster
  • profile picture
  • Member

Posted 22 January 2013 - 19:35 PM

good point also!!! didn't think of it victor!!! ;)

[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]

Shawon
  • profile picture
  • Member

Posted 23 January 2013 - 06:54 AM

[color=#282828][font=helvetica, arial, sans-serif]Hi victor,[/font][/color]
[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:[/color][/font][color=#282828][font=helvetica, arial, sans-serif] . [/font][/color][color=#282828][font=helvetica, arial, sans-serif] but i no need to select this automatically . can u tall me how to solve it?[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]Thank you [/font][/color]

victor
  • profile picture
  • Member

Posted 23 January 2013 - 07:15 AM

Shawon, make a screenshot and share it here.

Shawon
  • profile picture
  • Member

Posted 23 January 2013 - 08:30 AM

Its My problem

victor
  • profile picture
  • Member

Posted 23 January 2013 - 08:40 AM

maybe there is an wrong config for this library?

Shawon
  • profile picture
  • Member

Posted 23 January 2013 - 08:45 AM

i use your same code and database . from first post. only a little change on 'Url'
[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]

victor
  • profile picture
  • Member

Posted 23 January 2013 - 09:25 AM

So, send me your controller and database dump in private message.

maru
  • profile picture
  • Member

Posted 25 January 2013 - 21:46 PM

Victor! u r a genius! thank u so much for share this awesome library!
Regards! :)

martinsnihur
  • profile picture
  • Member

Posted 27 January 2013 - 03:59 AM

Hi, this is my first post, first of all I want to congratulate you for your work in the library ..
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.