set_relation with where based on current record
- Single Page
Posted 04 April 2012 - 18:09 PM
Is it possible for this where clause to refer to a field value from the current record?
For example, I have a table of accounts and a table of users. Each user is related to a single account, but each account also has an account owner, which relates to a single user.
The account owner must have an account_id that matches the current account. Otherwise it would be possible to set the account owner to a user that doesn't belong to that account.
Does that make sense? If so, is it possible?
Thanks in advance.
Posted 09 April 2012 - 10:19 AM
More specifically, let's say that I have a table users that can be connected 1-n with the accounts. And I want to have another table that holds a payment for something but we have to select the user and an account of that user from which the payment will be done. I want to make something like the following in the add process:
$this->grocery_crud->set_table('payments')
->set_relation('user_id', 'users', '{id}: {name}')
->set_relation('account_id', 'accounts', '{id}: {bank}', array('user_id' => 'payments.user_id'));
Where payments.user_id will be the user that was selected from the above dropdown menu.
Can I make something like that in grocery CRUD?
Posted 09 April 2012 - 10:25 AM
Posted 10 April 2012 - 08:06 AM