Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Afform Gui - Add support for entityRef fields #20216

Merged
merged 1 commit into from
May 14, 2021

Conversation

colemanw
Copy link
Member

@colemanw colemanw commented May 4, 2021

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.

@civibot
Copy link

civibot bot commented May 4, 2021

(Standard links)

@civibot civibot bot added the master label May 4, 2021
'defaults' => "{'url-autofill': '1'}",
'defaults' => "{
data: {
source_contact_id: 'user_contact_id',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@colemanw does source_contact_id show up in the UI? just wondering if this is changeable and what would user_contact_id reference if its an anon submission?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is the default and can be changed, but I think it's a sensible default. It makes adding a new activity look like this:
image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(also see Comments in PR description about this)

@seamuslee001 seamuslee001 self-assigned this May 4, 2021
@colemanw colemanw marked this pull request as ready for review May 13, 2021 04:07
@seamuslee001
Copy link
Contributor

@colemanw can you rebase please

Adds a widget for EntityRef and allows it to be changed to Number (for entering ID)
or Select (for choosing another entity on a form).
@seamuslee001 seamuslee001 merged commit fc436be into civicrm:master May 14, 2021
@seamuslee001 seamuslee001 deleted the afformEntityRef branch May 14, 2021 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants