allow creating related records from SearchKit#35665
Merged
Merged
Conversation
|
🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷 Introduction for new contributors...
Quick links for reviewers...
|
Contributor
Author
|
test this please |
Member
|
Thanks @MegaphoneJon this makes sense. Now that I think of it, I wonder why we aren't just always converting Create to Save here... might be that for some API entities there's a bigger difference btw the two. Anyway this looks great! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
I saw that 6.13+ supports creating SearchKit links that take action on a different entity. However, this fails if the API action you want to use is
create.Before
Can't use
createin a searchKitTask hook.After
Can.
Technical Details
Before this PR, it's assumed that any
createaction was on the same entity as the record being viewed. So theidisn't helpful because you can't pass an id to a created record. Additionally, the way that SearchKit passes the ID is in an array element namedrecords- whichsavesupports butcreatedoes not.This PR takes advantage of the similarity between the
createandsaveAPIs - if you usecreatewith anidField, it's converted to asave.Comments
I considered just adding a note in the docs that
createwasn't supported, just usesave- which is what I'd have done if I valued my time more. But it seems arbitrary to support all API actions except one here.