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

[5.x] Allow extra x-data to be passed to alpine forms #10174

Merged
merged 2 commits into from
May 28, 2024

Conversation

ryanmitchell
Copy link
Contributor

@ryanmitchell ryanmitchell commented May 23, 2024

We use the Alpine form driver and precognition forms on most of our sites. For some forms you need to pass extra x-data beyond what is available in the blueprint fields, for example something from the page context, logged in user etc etc.

It would be useful to be able to add to the x-data Statamic generates, so this PR enables you to do that:

{{ form:test js="alpine:form" \x-data='{"something_extra": "value"}' }}

or

{{ form:test js="alpine:form" :x-data="some_variable" }}

I've intentionally made it that passed x-data takes precedence over the x-data Statamic generates, so values can be overwritten if necessary.

@robdekort
Copy link
Contributor

I'm in the same boat right now and this is exactly what I need. Thank you Ryan!

@jasonvarga jasonvarga merged commit 4527685 into statamic:5.x May 28, 2024
19 checks passed
@ryanmitchell ryanmitchell deleted the feature/x-data-on-alpine-forms branch May 28, 2024 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants