Lookup fields

Archived from the Xataface Users forum.

fredo2906 — Mon Nov 26, 2012 11:14 pm

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?


fredo2906 — Tue Nov 27, 2012 12:48 am

Let me know if you want some clarification.


fredo2906 — Tue Nov 27, 2012 1:08 am

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.