⚠ 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)



Assem Abdul-Mahmood
  • profile picture
  • Member

Posted 09 August 2013 - 22:34 PM

First, Thank you so much Victor for your library and your continuous  support.

I used your library with grocery CRUD v 1.4.0, but I have countered this error 


A PHP Error was encountered

Severity: Notice

Message: Undefined variable: output

Filename: controllers/Cfs.php

Line Number: 165

 // which is 

 $output->output.= $js;

please any idea let me know.


hkgeeks
  • profile picture
  • Member

Posted 27 August 2013 - 15:57 PM

Hi Victor,

 

I am new to grocery_crud and jquery, would you mind to tell me what the expected return value(format) from "get_items/goods_state/1" ?

I had follow your sample to do it once, the ajex-loading.gif is keep running. I discover .getjson is querying a url - www.mydomain.com/get_items/goods_state/1 , I try to add a controller that names get_items and the function goods_state

 

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Get_items extends CI_Controller {

	public function __construct() 
	{
		parent::__construct();
		
		$this->load->helper('html');
		$this->load->helper('url');
		$this->load->model('data_model');
	}

	public function index()
	{
		redirect('home');
	}
	
	public function goods_state()
	{
		$sid = $this->uri->segment(3);
		
		$arstate = $this->data_model->get_state_by_id($sid);
		echo $arstate;
	}
}

My purpose of the this usage is here : /topic/1998-table-relation/

 

Thank you for your helping

 

--------- Update ----------

Sorry to my mistake, I changed the config to

'url'=>base_url().'index.php/'.__CLASS__.'/'.__FUNCTION__.'/' 

its work, Thanks.

 


David Romero León
  • profile picture
  • Member

Posted 10 September 2013 - 07:38 AM

Hi, I'm Colombian
I need your help
 
I need you to call a selection list only two fields automatically fill
 
agency = selection list
region = autofill
area = autofill
 
these data is in a single table
 
-
- Table structure for table `office`
-
 
CREATE TABLE IF NOT EXISTS `offices` (
   `id_angency` int (11) NOT NULL AUTO_INCREMENT,
   `agency` varchar (100) NOT NULL COLLATE latin1_general_ci,
   `address` varchar (100) NOT NULL COLLATE latin1_general_ci,
   `phone` varchar (20) NOT NULL COLLATE latin1_general_ci,
   `id_municipio` int (11) NOT NULL,
   `nit` varchar (20) NOT NULL COLLATE latin1_general_ci,
   `region` varchar (50) NOT NULL COLLATE latin1_general_ci,
   `area` varchar (50) NOT NULL COLLATE latin1_general_ci,
   PRIMARY KEY (`id_agency`)
) ENGINE = MyISAM DEFAULT CHARSET = latin1 COLLATE = latin1_general_ci AUTO_INCREMENT = 222;
 
-
- Dumping data for table `office`
-

a hand with this please......


Robert
  • profile picture
  • Member

Posted 19 September 2013 - 06:54 AM

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

		$fields = array(
		'judet' => array(// first dropdown name
		'table_name' => 'judete', // table of country
		'title' => 'nume', // country title
		'relate' => null // the first dropdown hasn't a relation
		),
		'firma' => array(// second dropdown name
		'table_name' => 'clienti', // table of state
		'title' => 'denumire', // state title
		'id_field' => 'id', // table of state: primary key
		'relate' => 'judet2', // table of state:
		'data-placeholder' => 'Selectează Firma' //dropdown's data-placeholder:
		)
		);
		$config = array(
		'main_table' => 'judete',
		'main_table_primary' => 'id',
		"url" => site_url('main/agenti_program/') . '/',
		);

		$categories = new gc_dependent_select($crud, $fields, $config);
		$js = $categories->get_js();
		$output = $crud->render();
		$output->output.= $js;
		

		$this->_agenti_program_output($output);

Im using GC 1.4.1 for the add part it works perfect but when i use edit i get on error (i think is problem with my code but i cant find it..... if someone can help) 

A PHP Error was encountered

Severity: Notice

Message: Undefined index: judet

Filename: libraries/gc_dependent_select.php

Line Number: 103

Forgot about the relation :

 
$crud->set_relation('judet','judete','nume');

davidoster
  • profile picture
  • Member

Posted 19 September 2013 - 08:39 AM

[member=robert] refer to these: 

http://www.dmxzone.com/go/13811/php-getting-notice-undefined-index/

http://siliconstation.com/how-fix-php-notice-undefined-index/


Robert
  • profile picture
  • Member

Posted 20 September 2013 - 11:24 AM

Thanks for the replay .. will check it out and see .. 


kenshicu
  • profile picture
  • Member

Posted 07 November 2013 - 16:34 PM

hello I was installing a web application with GC (using the dropdowns dependent) on Linux and as there is casesensitive
It made ??this mistake and changed in the library:

line 210:

$js.= '$.getJSON(\'' . $this->config['url'] . $this->segment_name . '/' . $dd_dropdowns[$i]['field'] . '/' . '\'+select_value, function(data) {';


for this:
 

$js.= '$.getJSON(\'' . strtolower($this->config['url']) . strtolower($this->segment_name) . '/' . strtolower($dd_dropdowns[$i]['field']) . '/' . '\'+select_value, function(data) {';


and then ran :lol:

 


sorry my bad english


ohnague
  • profile picture
  • Member

Posted 08 November 2013 - 14:34 PM

sorry my bad english google translate My question is formulated to whether you can succeed in creating the library to end the relationship either by set_relation_n_n

davidoster
  • profile picture
  • Member

Posted 10 November 2013 - 06:38 AM

hello I was installing a web application with GC (using the dropdowns dependent) on Linux and as there is casesensitive
It made ??this mistake and changed in the library:

line 210:

$js.= '$.getJSON(\'' . $this->config['url'] . $this->segment_name . '/' . $dd_dropdowns[$i]['field'] . '/' . '\'+select_value, function(data) {';

for this:
 

$js.= '$.getJSON(\'' . strtolower($this->config['url']) . strtolower($this->segment_name) . '/' . strtolower($dd_dropdowns[$i]['field']) . '/' . '\'+select_value, function(data) {';

and then ran :lol:

 

sorry my bad english

 

[member=kenshicu], I had to do this in order to make it run.


davidoster
  • profile picture
  • Member

Posted 10 November 2013 - 06:40 AM

sorry my bad english google translate My question is formulated to whether you can succeed in creating the library to end the relationship either by set_relation_n_n

 

I am sorry but I can not understand the translated question.

This extension, dependant dropdown library is totally different from the set_relation_n_n.


Musto Hary
  • profile picture
  • Member

Posted 12 December 2013 - 04:00 AM

Im sory,.. my english so bad,.... I am newbie and I need dropdown like my schema,... anyone can help me please...


jinbatsu
  • profile picture
  • Member

Posted 28 December 2013 - 20:02 PM

I just try it with GC 1.4.1 and it works.

Very valueable plugin, thanks!


klahnen
  • profile picture
  • Member

Posted 30 December 2013 - 17:21 PM

Hi,

 

Your library is great, but I think I found an issue. When you "view" record dependent fields are not being displayed but when you "edit" or "add" it just works perfectly.

 

Please let me know if I am missing something or where can I start debugging.

 

Regards.


davidoster
  • profile picture
  • Member

Posted 30 December 2013 - 17:45 PM

Hi,

 

Your library is great, but I think I found an issue. When you "view" record dependent fields are not being displayed but when you "edit" or "add" it just works perfectly.

 

Please let me know if I am missing something or where can I start debugging.

 

Regards.

 

Hello [member=klahnen] and welcome to the forums.

This library hasn't been updated for the new feature of view that the Grocery CRUD library now has and thus it won't work for the dependent fields.


engr zardari
  • profile picture
  • Member

Posted 13 March 2014 - 12:25 PM

Hi to Experts,

 

 

I stucked i a Problem When Playing with Drop Downs... I tried to use this
 /topic/1087-updated-24112012-dependent-dropdown-library/

 

but actually my requirement is quite different

 

i have a table

 

fwld_products
 

in which i am addind all other table's categories, from

 

fwld_cat_main (main Category's ID),

 

fwld_cat_sub1 (sub1 Category's id)

 

fwld_cat_sub2 (sub2 Category's id)

 

fwld_cat_sub3 (sub3 Category's id)

 

 

I want to Display Dropdown in such a way, when user Selects main Category, the Drop Down Appear (sub1) Having Data related to main category and when sub1 selected drop down appear (sub2) showing data related to sub1, and sub2 selected and drop down appear(sub3) to show data related to Drop down (sub2).

 

when submitted Finnally data inserted to fwld_products

 

 

here i am attaching ERD, and Result As Well

 

 

Please Solve my Problem as soon as possible

 


engr zardari
  • profile picture
  • Member

Posted 13 March 2014 - 12:27 PM

Hi to Experts,

 

 

I stucked i a Problem When Playing with Drop Downs... I tried to use this
 /topic/1087-updated-24112012-dependent-dropdown-library/

 

but actually my requirement is quite different

 

i have a table

 

fwld_products
 

in which i am addind all other table's categories, from

 

fwld_cat_main (main Category's ID),

 

fwld_cat_sub1 (sub1 Category's id)

 

fwld_cat_sub2 (sub2 Category's id)

 

fwld_cat_sub3 (sub3 Category's id)

 

 

I want to Display Dropdown in such a way, when user Selects main Category, the Drop Down Appear (sub1) Having Data related to main category and when sub1 selected drop down appear (sub2) showing data related to sub1, and sub2 selected and drop down appear(sub3) to show data related to Drop down (sub2).

 

when submitted Finnally data inserted to fwld_products

 

 

here i am attaching ERD, and Result As Well

 

 

Please Solve my Problem as soon as possible

 


engr zardari
  • profile picture
  • Member

Posted 13 March 2014 - 12:38 PM

Hi to Experts,

 

 

I stucked i a Problem When Playing with Drop Downs... I tried to use this
 /topic/1087-updated-24112012-dependent-dropdown-library/

 

but actually my requirement is quite different

 

i have a table

 

fwld_products
 

in which i am addind all other table's categories, from

 

fwld_cat_main (main Category's ID),

 

fwld_cat_sub1 (sub1 Category's id)

 

fwld_cat_sub2 (sub2 Category's id)

 

fwld_cat_sub3 (sub3 Category's id)

 

 

I want to Display Dropdown in such a way, when user Selects main Category, the Drop Down Appear (sub1) Having Data related to main category and when sub1 selected drop down appear (sub2) showing data related to sub1, and sub2 selected and drop down appear(sub3) to show data related to Drop down (sub2).

 

when submitted Finnally data inserted to fwld_products

 

 

here i am attaching ERD, and Result As Well

 

 

Please Solve my Problem as soon as possible

 


Paul Savostin
  • profile picture
  • Member

Posted 15 March 2014 - 23:58 PM

Its My problem

 

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]

i have face to this problem too and fix for this next -  add default empty <option value="" selected></option> to edit callback method in 

"...   if ($item[$this->fields[$field_info->name]['id_field']] == $value)...." if this condition FALSE

 

string number 163 of this library

By the way special thanks to Victor for this amazing lib


victor
  • profile picture
  • Member

Posted 19 March 2014 - 23:30 PM

i have face to this problem too and fix for this next -  add default empty <option value="" selected></option> to edit callback method in 

"...   if ($item[$this->fields[$field_info->name]['id_field']] == $value)...." if this condition FALSE

 

string number 163 of this library

By the way special thanks to Victor for this amazing lib

Hi! Have you solved the problem?


Paul Savostin
  • profile picture
  • Member

Posted 21 March 2014 - 11:13 AM

Hi! Have you solved the problem?

Hi Victor, Privet iz bratskoy Ukraini) Yeah, like i sad before, just add empty select tag was enough

Really, you're the CRUD Hero! ;)

Looking for solution with uploading images, and was read your topic about it - complicated for me now :)

my english is also not the best so that we understand each other well i think :D