Lookup field using the same field values

Hi everyone,

I have an entity Person with a field Role. In the edit screen, I would like to use LookupField widget on the field Role. The options of this LookupField should come from the same field Role in the entity Person. Basically using previously used roles.

Anyone can tell how can achieve this ?

Thanks,
Samy

Hi Samy,

Then how are you going to enter something for the first Person? There will be no options in the Role field, right?

Yes, that’s right. The first time it will be empty, but then as new records are created the lookup will be populated with the corresponding values.

Hi,

What you can do is to store the role as a string Attribute in the person entity.

When opening a screen you configure a Lookup Field for the role attribute.

In the controller you manually populate the options via a “select * from person“.

I created an example for you here:

suggestion-from-history

I hope this helps :slight_smile:

Cheers
Mario

1 Like

Hi Mario,

Many thanks, that works !

Best,
Samy