Afform Gui - Add support for entityRef fields #20216
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Adds a widget for EntityRef to autocomplete contacts & other entities. Allows it to be changed to Number (for entering ID) or Select (for choosing another entity on a form).
Before
Fields that pick other entities (e.g. contact reference fields like "Activity Created by") are not supported by Afform.
After
EntityRef fields supported.
Comments
With this PR, creating an activity is finally functional. When you add one to the form, you'll see on the left side under "Values" the "Created by" field is pre-filled with "Current User". You can change it to an existing contact in the database, or have it populate from a contact on the form.
The Form Layout also supports EntityRef fields. By default they are an autocomplete to pick existing contacts, etc. from the database. You can also change the widget from EntityRef to Number or Select to either enter an id or select an entity on the form.