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

[4.x] Allow using Global Set variables in form email configs #8892

Merged
merged 3 commits into from
Oct 30, 2023

Conversation

duncanmcclean
Copy link
Member

This pull request allows for using Global Set variables in form configs.

Closes #2635.

Example

For example you could have a "Company Information" global with Name & Email fields.

Then, when configuring form emails, you'd be able to reference the global set data just like you would in a normal Antlers template: {{ company_information:email }}

CleanShot 2023-10-30 at 12 10 33

@duncanmcclean duncanmcclean changed the title Allow using Global Set variables in form configs [4.x] Allow using Global Set variables in form configs Oct 30, 2023
@jasonvarga jasonvarga changed the title [4.x] Allow using Global Set variables in form configs [4.x] Allow using Global Set variables in form email configs Oct 30, 2023
@jasonvarga jasonvarga merged commit b3e634f into 4.x Oct 30, 2023
31 checks passed
@jasonvarga jasonvarga deleted the allow-using-globals-in-form-config branch October 30, 2023 19:05
@wm-simon
Copy link

@duncanmcclean Hey, is it possible to use page variables in the settings, too? Like {{ page:title }}, {{ page:id }}, etc...

@duncanmcclean
Copy link
Member Author

@duncanmcclean Hey, is it possible to use page variables in the settings, too? Like {{ page:title }}, {{ page:id }}, etc...

No, it's not possible since the form emails have no context of the page you submitted the form on.

To workaround that though, you could pass the page's title/ID along to the form as a hidden input then do whatever you need to do with it.

@wm-simon
Copy link

I've added the fields hardcoded to the form:

    <input
    type="hidden"
    name="outlook_id"
    value="{{ bereiche:outlook_id }}"    
    >
    <input
    type="hidden"
    name="page_title"
    value="{{ page:title }}"    
    >

The variables are shown on the website. Now I have to show the content in the mail subject.
That's my code:
[{{outlook_id}}] Neue Bewerbung von {{ first_name }} {{ last_name }} als {{ page_title }}

First and last name are shown in the subject, but not my fields.

@jasonvarga
Copy link
Member

The fields need to exist in the form's blueprint.

@wm-simon
Copy link

wm-simon commented Nov 17, 2023

I've tried this, but I couldn't find a solution to show the variable content. Do I need to add my variable to the field, for example, as the default value? I've tried page:title and {{ page:title }}, but the variable is not parsed with the value.

These are not working:

    <input
    type="{{ input_type ?? 'text' }}"
    name="{{ handle }}"
    value="{{ {{ default }} }}"    
    >
    <input
    type="{{ input_type ?? 'text' }}"
    name="{{ handle }}"
    value="{{ default }}"    
    >

I have no idea, how I can define the field names and get the page content to send it with the form.

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.

[Forms] Impossible to use globals in form settings
3 participants