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 - allow ids to be passed directly into the directive #23656

Merged
merged 1 commit into from
Jun 9, 2022

Conversation

colemanw
Copy link
Member

@colemanw colemanw commented Jun 1, 2022

Overview

This gives Submit Forms the same feature as Search Forms, entity ids can be passed directly into the directive as 'options', allowing ids to be passed around internally.

Before

With an Afform named MyForm and an entity named Contact 1, you could enable url-autofill for that entity and append #/?Contact1=123 to the url to supply an existing contact id.

After

The above still works, but to facilitate embedding an afform into other places e.g. a block or a contact summary tab, you can pass the id directly into the directive e.g.:

<my-form options="{Contact1: 123}"></my-form>

Comments

Note that this same technique already works with Afforms of type "Search" so this just extends the functionality to work with submission forms as well.

Technical Details

See discussion at systopia/de.systopia.eck#48 (comment)

@civibot
Copy link

civibot bot commented Jun 1, 2022

(Standard links)

@totten
Copy link
Member

totten commented Jun 2, 2022

@colemanw The "After" example isn't readable?

@colemanw
Copy link
Member Author

colemanw commented Jun 2, 2022

@totten fixed

@jensschuppe
Copy link
Contributor

I can confirm this works with the ECK implementation (systopia/de.systopia.eck#48), where an Afform for editing a custom entity is being embedded in a tabset and loads with current entity values. However, submitting the embedded form does not seem to work, the entity values are not being updated.

…through the URL

This gives Submit Forms the same feature as Search Forms, entity ids can be passed
directly into the directive as 'options', allowing ids to be passed around internally.
@colemanw
Copy link
Member Author

colemanw commented Jun 8, 2022

@jensschuppe good catch. It was not passing the id correctly to the submit action. I've updated this PR, so now it saves.

The UX is still not great because it doesn't refresh the page so you still see old data on the "View" tab, but I think we can address that in a followup PR.

@eileenmcnaughton eileenmcnaughton merged commit ce2ccec into civicrm:master Jun 9, 2022
@colemanw colemanw deleted the afformOptions branch June 9, 2022 01:37
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.

4 participants