Page 1 of 1

Lookup fields

PostPosted: Mon Nov 26, 2012 11:14 pm
by fredo2906
Hi,
If I post this message at the wrong place, please let me know.

I would like to let a user select a record from a table A and save the id into another table.

I set the following in fields.ini file for the table Servers_has_Alarms :
[Servers_id]
widget:type=lookup
widget:table=Servers

The table into which i want to insert a record is :
Servers_has_Alarms
contains a field Servers_id

The box does not return the id of the selected record, which means the insert fail at the end.

Any idea?

Re: Lookup fields

PostPosted: Tue Nov 27, 2012 12:48 am
by fredo2906
Let me know if you want some clarification. :D

Re: Lookup fields (Solved)

PostPosted: Tue Nov 27, 2012 1:08 am
by fredo2906
I found the solution.
Create a delegate class mytable.php.
use the beforeSave trigger
Get the output from $record->value('myfield')
and ... get the ID from the returned value, and use $record->setValue to set the field with the good id.

Hope this will help someone else.