Hope someone can point me in the right direction - this problem is driving me nuts
I'm trying to filter the valuelist entries for a field based on records owned by the logged in user.
For example:
I have a "cash_accounts" table which has all the user's bank accounts:
mysql> describe cash_accounts;
+---------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+----------------+
| id | int(11) | | PRI | NULL | auto_increment |
| user_id | int(11) | | | 0 | |
| country_id | int(11) | | | 0 | |
| currency_id | int(11) | | | 0 | |
| description | varchar(100) | | | NULL | |
| interest_rate | float | | | 0 | |
+---------------+--------------+------+-----+---------+----------------+
..and for example the property_costs table - when I add a new record, I don't want to have all the bank account details from cash_accounts listed, only the one for this user.
mysql> describe property_costs;
+-----------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+--------------+------+-----+---------+----------------+
| id | int(11) | | PRI | NULL | auto_increment |
| user_id | int(11) | | | 0 | |
| property_id | int(11) | | | 0 | |
| cash_account_id | int(11) | | | 0 | |
| description | varchar(100) | | | NULL | |
| value | bigint(20) | | | 0 | |
+-----------------+--------------+------+-----+---------+----------------+
My fields.ini in tables/property_costs has:
[__filters__]
user_id="$user->val('id')"
My valuelists.ini has:
[cash_account_id]
__sql__ = "select id,description from cash_accounts order by id asc"
..which is obviously selecting all the records - can I use a delegate class to filter these results ?
Any help would be greatly appreciated !
Thanks,
Allan.
PS - thanks for an awesome product