Need to filter relation dropdown
- Single Page
Posted 21 November 2012 - 20:13 PM
Events
id|title|owner_id
Users
id|email address
Users_Groups
group_id|user_id
On my events CRUD form, I need the dropdown to show users (This works great) but I need the list to only show users who belong to group_id 1 in the Users_Groups table.
How would I accomplish this? I believe we need to use the set_model method, but I'm having a difficult time understanding the documentation in that regard.
Posted 22 November 2012 - 06:09 AM
Posted 22 November 2012 - 06:22 AM
Posted 22 November 2012 - 15:00 PM
From the documentation it seems you can not add a table, but it should be possible to use tablename.fieldname in a $crud->where() call.
If that works, it may be a hint to update the documentation for that?
Regards,
Kobus
Posted 26 November 2012 - 19:53 PM
SELECT * FROM (`users`) WHERE `users_groups`.`group_id` = 1 AND users_groups.user_id = users.id
This would work perfectly if I could change that FROM `users` to be FROM `users`, `users_groups`
Posted 30 November 2012 - 20:32 PM
/topic/264-join-tables/#entry1018
Posted 31 December 2012 - 13:14 PM
Did you manage? You could also set a relation, that will automatically create the correct join, when in conjuntion with the $crud->where() clause, you can probably do what you wanted to.
Please let us know?