Jump to content


carperolm

Member Since 19 Dec 2013
Offline Last Active Mar 10 2016 11:40 AM
-----

Topics I've Started

set_relation_n_n where on list view

01 March 2016 - 06:19 PM

Hi there,
 
I'm getting mad with this issue.
 
I have a n:n relation 
 
$where = "department_id = 1";
$crud->set_relation_n_n('departments','exp_dep','departments','exp_id','department_id','name, null, $where);
 
I would like to filter the listing view with a condition over a field in departments table departments.department_id
 
Everything works ok on edit and add views but is not working on listing state. I've been searching on forum but I didn't found any help.
 
If I use 
 
$crud->where('department_id',1);  I get a mysql error:
 
Unknown column 'department_id' in 'where clause'

 

Could anyone help me?

 

 

Thanks in advance.

 
 

 


gc_dependent_select library with condition

10 February 2016 - 12:39 PM

Hello

For dependent dropdowns I use gc_dependet_select library by Victor (amazing library)

 

But I'm not sure if I can do the following:

 

I have this database structure:

COUPONS
coupon_id
user_id
category_id
...

USERS
user_id
city_id
...

CATEGORIES
category_id
city_id
...
$fields = array(
// first field:
'user_id' => array( // first dropdown name
'table_name' => 'users', // table of country
'title' => 'username', // country title
'relate' => null // the first dropdown hasn't a relation
),
// second field
'category_id' => array( // second dropdown name
'table_name' => 'categories', // table of state
'title' => 'name', // state title
'id_field' => 'category_id', // table of state: primary key
'relate' => 'city_id', // table of state:
'data-placeholder' => 'Select users first' //dropdown's data-placeholder:
)
);

 

I would like to generate a dependant dropdown in COUPONS, where I select the users first and then the categories with the same city_id as the user selected.

 

It's possible?

 

Thanks in advance