⚠ 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

dependant dropdowns



draven

draven
  • profile picture
  • Member

Posted 28 May 2015 - 14:11 PM

Hi all, i have two table with this fields:

table1:

id1

title1

 

table2:

id2

id_of_table1

title2

 

after this i have another table with this fields:

table3:

id3

id_of_table1

id_of_table2

title3

 

i would like to create a form of insert (in the table3) with two dropdown and an input field, when i make this the first dropdown is populated correctly but when i select one of the records, the second dropdown remain in disable mode.

 

this is my code:

 

$this->load->library('grocery_CRUD');
$crud new grocery_CRUD();

$crud->set_theme('flexigrid');
$crud->set_table('gruppi');
$crud->set_subject('Gruppo');
$crud->required_fields('idapc''idset''gruppo');
$crud->columns('idapc''idset''gruppo');
$crud->display_as('idapc','Ass. Prima Casa');
$crud->display_as('idset','Settore');
$crud->display_as('gruppo','Gruppo');
$crud->set_relation('idset','settori','settore');
$crud->set_relation('idapc','apc','apc');

$this->load->library('gc_dependent_select');

$fields array(
'idapc' => array(// first dropdown name
'table_name' => 'apc'// table of country
'title' => 'apc'// country title
'relate' => null // the first dropdown hasn't a relation
),
'idset' => array(// second dropdown name
'table_name' => 'settori'// table of state
'title' => 'settore'// state title
'id_field' => 'idset'// table of state: primary key
'relate' => 'idapc'// table of state:
'data-placeholder' => 'Scegli Settore' //dropdown's data-placeholder:
)
);
$config array(
'main_table' => 'gruppi',
'main_table_primary' => 'idgrp',
'url' => base_url() .'index.php/'__CLASS__ '/' __FUNCTION__ '/'
);
$categories new gc_dependent_select($crud$fields$config);
$js $categories->get_js();

$output $crud->render();
$output->output.= $js;

$this->load->view('gruppi_view',$output);

 

the project of this code contains codeigniter, grocery crud, Victor's library and bootstrap.... with bootstrap, the project have more and more js contents... so i thinked that the problem was this and i created a controller without loading bootstrap views (only grocery and Victor's library) but the result is the same  :(

 

the gc_dependent_select is the 1.2 version and grocery is the 1.3.3 version

 

help me  :( thanks a lot