Paint layout in custom form emails


(Hugh McMaster) #1

Matrix Version: 5.4.3.1

I encountered the same issue with formatting custom form HTML email as in WYSIWYG breaking HTML in Custom form emails.

By following @Bart’s suggestion of using a paint layout, I’ve been able to format the HTML email as I need (i.e. only showing completed fields). This works perfectly when logged in. But when I submit the form as a public user, no output is sent in the email.

The custom form and the paint layout are live, and the Public user has been granted read permissions for both assets.
I’m using the Default Type format in the Paint Layout. And submission logging is enabled.

Are there some other settings I need to use?

Thank you


(Hugh McMaster) #2

I’ve also tried using %globals_asset_contents_paint_layout_id_<paint_layout_id>:%form_submission_id%%.

The expected contents only appears when I’m logged in. Public users see nothing.

Any ideas?


(Bart Banda) #3

I’m guessing it’s because the public user doesn’t actually have read access to that form submission asset when it is generated via the globals keyword.

Another thing to try might be to send the data of the form submission as a get variable instead, something like
%globals_asset_contents_raw:1234^with_get:data={globals_post}%. Assuming the form submission data is all in that POST request at that time. If you are using a confirmation screen you might need to pass it in a different way.
Would that work?


(Hugh McMaster) #4

Hi Bart,

Thank you for responding.

I tried making granting all submissions public read access (and enabling the change for new children). There was no difference in testing (which is good, since I wouldn’t recommend doing this on a production environment).

This was interesting. The submission contents were inserted into the email even when submitted by a public user. Unfortunately, I don’t see a means of associating that with a paint layout.


(Bart Banda) #5

Well if you use something like %globals_asset_contents_raw:1234^with_get:data={globals_post}%, you might not necessarily need to use a PL, just need to use a Standard Page to format the content. So #1234 in this case is the Standard Page asset and within it, if you have access to the globals_post data, you should be able to access it via %globals_get_data% and go from there?


(Hugh McMaster) #6

Hi Bart,

Sorry for the delayed response.

Pulling in contents from the Standard Page asset works perfectly, although I needed to use the
%nested_get_X% keyword format. I’m using the Standard Page asset as a template for a table, so that I only display fields the user actually filled in.

In case it helps anyone looking to implement a similar solution, a conditional block in the Standard Page asset will look something like the following:

<table>
    <tbody>
        <tr>    
            <td>
                What is your enquiry about?
            </td>
            <td>
                %nested_get_data^json_decode^index:q72518\:q7%
            </td>
        </tr>
        %begin_nested_get_data^json_decode^index:q72518\:q8%
        <tr>
            <td>
                Specific topic:
            </td>
            <td>
                %nested_get_data^json_decode^index:q72518\:q8%
            </td>
        </tr>
        %end_nested_get_data%
    </tbody>
</table>

You can use additional code to conditionally add several rows of a table etc.


(Hugh McMaster) #7

Actually, since the POST data still exists at the time of email creation, just use the simpler keyword sequence:
%globals_post^index:q72518\:6% or similar. It’s much easier and supports quote marks and special characters without requiring complicated workarounds.


(TT) #8

Hi Hugh,

I have been using the same keyword sequence as you in the above e.g.
%globals_post^index:q121579:q2% and it’s been working great. However it wont print out date fields.

%globals_post^index:q121579:q7%

Any idea how to print out those using the sequence above?

Thanks,

Tim


(Hugh McMaster) #9

Hi Tim,

The datetime field is actually several different component fields - day, month, year, hour, minute and second.

As you found out, you can’t print the datetime value in the same way as a text field, for example.

So, to find out why the datetime values aren’t printing, add %globals_post% to your custom layout asset. This way, you can see what’s happening during the POST request at submission-time.

As a simple example, I made a custom form with a single datetime component. In the email output, %globals_post% was substituted to become:

{"SQ_FORM_81651_PAGE":"1","form_email_81651_referral_url":"","q81651_q1_show":"dmy","q81651_q1_value":"d":"13","m":"9","y":"2018","h":"","i":"","s":""},"form_email_81651_submit":"Submit"}

As you can see, each datetime field is a separate key/value pair in an object, which itself is the value of q81651_q1_value.

To print the information you need, you’ll have to access each datetime field index individually. So, to print the year, for example, you would add %globals_post^index:q81651_q1_value^index:y% to your custom layout.

Hope that helps. If you’ve got any questions, just ask.


(TT) #10

Thanks for the quick reply Hugh!

I had tried the globals_post and got back the result but had put it in the wrong format:

%globals_post^index:q81651_q1_value^index:[y]%

Yours worked perfectly.

Many thanks!

Tim


(Adeel) #11

Hi Bart, I am using the following code as well for a conditional web form email. My only issue is that it doesn’t print the file upload field data. I have also tried the “%globals_post%” for email out put and it is missing the data for file upload fields. Any idea why that is happening thanks?

Specific topic: %nested_get_data^json_decode^index:q72518\:q8% %end_nested_get_data%

(Adeel) #12

The %globals_post^index:q72518:6% doesn’t print anything if it is a file upload field. Ay idea why?


(Tarman) #13

I do not think %globals_post% keyword will give any information on file upload question type even if it is file upload field. $_POST does not include any information on files. $_FILES will have all the information regarding the uploaded file. Matrix does not have keyword for $_FILES