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 - Enable creating event from a template #27058

Merged
merged 1 commit into from
Aug 18, 2023

Conversation

colemanw
Copy link
Member

Overview

Enables selecting an event template when using Afform to create a new event.

Before

No "Event Template" field available on Afform.

After

How to use this feature:

  1. Make an Afform for Events
  2. Drag required fields to the form (at minimum, Title, Start Date, Event Type)
  3. Drag the "Event Template" field to the form
  4. Give the form a url, save, and visit the form.
  5. Select a template from the list, the rest of the form will be autofilled from the template.
  6. Update other fields as desired and save.
  7. The saved event will inherit all data from the event template.

Technical Details

This expands autofill functionality to work with create actions in addition to update.

@civibot
Copy link

civibot bot commented Aug 12, 2023

Thank you for contributing to CiviCRM! ❤️ We will need to test and review the PR. 👷

Introduction for new contributors
  • If this is your first PR, an admin will greenlight automated testing with the command ok to test or add to whitelist.
  • A series of tests will automatically run. You can see the results at the bottom of this page (if there are any problems, it will include a link to see what went wrong).
  • A demo site will be built where anyone can try out a version of CiviCRM that includes your changes.
  • If this process needs to be repeated, an admin will issue the command test this please to rerun tests and build a new demo site.
  • Before this PR can be merged, it needs to be reviewed. Please keep in mind that reviewers are volunteers, and their response time can vary from a few hours to a few weeks depending on their availability and their knowledge of this particular part of CiviCRM.
  • A great way to speed up this process is to "trade reviews" with someone - find an open PR that you feel able to review, and leave a comment like "I'm reviewing this now, could you please review mine?" (include a link to yours). You don't have to wait for a response to get started (and you don't have to stop at one!) the more you review, the faster this process goes for everyone 😄
  • To ensure that you are credited properly in the final release notes, please add yourself to contributor-key.yml
  • For more information about contributing, see CONTRIBUTING.md.
Quick links for reviewers

@civibot civibot bot added the master label Aug 12, 2023
@Guydn
Copy link

Guydn commented Aug 12, 2023

I will test it asap. Is the timezone included ?

@colemanw
Copy link
Member Author

I will test it asap. Is the timezone included ?

That's a complex topic. See https://lab.civicrm.org/dev/core/-/issues/2122

@Guydn
Copy link

Guydn commented Aug 13, 2023

I will test it asap. Is the timezone included ?

That's a complex topic. See https://lab.civicrm.org/dev/core/-/issues/2122

Yes, I saw the issue.

@Guydn
Copy link

Guydn commented Aug 13, 2023

I have tested and the event is created with all the fields :-).
Is there a possibility to load the information of the template (the title, the description , ...) so that the user sees the information coming from the template and is able to change the information if he wants to. Just like the way it works in CiviCRM. As soon as the template is selected, then all the fields are populated and it is possible to change the fields.

@colemanw
Copy link
Member Author

@Guydn yes that is how it works. When you select a template it will auto populate the fields on the afform. Is that not working for you?

@Guydn
Copy link

Guydn commented Aug 14, 2023

@colemanw I am missing something...
find below my configuration
Fdn Event temp 1
Fdn Event temp 3
Fields Title and description are texte and richtext
And the event template
Fdn event temp 4

@mlutfy
Copy link
Member

mlutfy commented Aug 15, 2023

I tested Guy's form, and when using a template, the network console shows:

Cannot process APIv4 request for Event1 (Event.get): Action is not approved

I'm logged-in as an admin, and the patch was applied on top of CiviCRM 6.65 (RC).

This expands autofill functionality to work with create actions in addition to update.
@colemanw colemanw force-pushed the afformEventTemplate branch from 88162ad to e2c263c Compare August 16, 2023 23:24
@colemanw
Copy link
Member Author

Thank you again @Guydn for testing and @mlutfy for debugging. Turns out it was overly-restrictive access checks. I've fixed them and updated this PR, I think it should work now for non-superadmins.

@mlutfy
Copy link
Member

mlutfy commented Aug 17, 2023

@colemanw New changes work for me. I tested as an anon users (with a form that allows it), and it populated the form correctly.

Is the test fail related? (core-matrix, action mapping)

@mlutfy
Copy link
Member

mlutfy commented Aug 18, 2023

jenkins, test this please

@mlutfy mlutfy added the merge ready PR will be merged after a few days if there are no objections label Aug 18, 2023
@colemanw
Copy link
Member Author

@mlutfy the test fail is unrelated to this PR

@mlutfy mlutfy merged commit 078fc3a into civicrm:master Aug 18, 2023
@colemanw colemanw deleted the afformEventTemplate branch August 18, 2023 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
master merge ready PR will be merged after a few days if there are no objections
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants