WYSIWYG breaking HTML in Custom form emails


(Evan Wills) #1

Matrix Version:

I have a form where there are some optional fieldsets that are conditionally hidden/shown in the form based on responses to preceding questions. If the user doesn’t fill in the fieldset I’d like to hide those questions in the email response to both the recipient and the receipt.

Custom form HTML emails still don’t support conditional keywords (e.g. %begin_response_XXXX_qYY%[question code]%end_response_XXXX_qYY%). So, previously I’ve used one of the following methods to hide content in form response emails, which has worked fine for years.

%

	
		%question_name_XXXXX_qY%
	
	
		%response_XXXXX_qY% %response_XXXXX_qZ^notempty:(Not empty text)^empty:(empty text)%
	

%response_XXXXX_qY^notempty:

or

%response_XXXXX_qY^notempty:^empty:%

It seems that since the upgrade to 5.4.3.1, Viper has gotten more fancy/officious with its rewriting of the HTML and now it breaks my email code.

The above code becomes the below code after you “Apply changes”
(Note the missing “%” from the end of the first line and the missing keyword (%response_XXXX_qYY^notempty:) from the start of the third line.

    
      
%question_name_XXXXX_qY%
      
      
         %response_XXXXX_qY^empty:N/A% %response_XXXXX_qZ^notempty(Not empty text)^empty:(empty text)% 
      
    

and


Does anyone know any way around this? Is it possible to switch off the WYSIWYG for Custom form HTML emails?


Paint layout in custom form emails
(Bart Banda) #2

Yea, it’s a recurring problem, and we are looking at ways to make custom form email formatting a lot better.

But if you are storing the form submission assets in Matrix, you can use a PL to format the email contents. Simply just put this in the email contents: %form_submission_id^as_asset:asset_contents_paint_layout_id_1234% where 1234 is your PL, and then you can format it there using standard keyword modifiers and conditions. You just need to use the %question_answer_xxxx_qx% format to get the value of a form field.


(Hugh McMaster) #3

Hi Evan,

Were you able to get Bart’s suggestion to work correctly for public users?

Thanks


(Evan Wills) #4

Hi @hmcmaster & @Bart

Sorry for the slow reply, the project that this is important for only runs twice a year and I had to do without last time. It’s on again so now I can devote more time to it.

YES!!! It worked a treat.

Thank you.


(Adeel) #5

Hi @Bart I have tried this solution for one of our forms. It doesn’t work for the public users. I have tried giving read/write permissions to the public users for the form submissions but it still doesn’t work.

Is there a way we can make this PL solution working for public users as well?


(Evan Wills) #6

@aforadeel My guess is that either your form (or paint layout) is in Safe Edit mode, your paint layout is still under construction or that the paint layout itself doesn’t have read permissions.

NOTE: it’s probably a bad idea to give the form public write access. (Sorry if I’ve misunderstood your comment “I have tried giving read/write permissions to the public users for the form submissions”)

It’s also possible that you haven’t got the paint layout keyword right. From memory, it took me a couple of goes to get it right. This is what I used in the email body:

%form_submission_id^as_asset:asset_contents_paint_layout_id_2314291%

(swap 2314291 for whatever the ID for your paint layout is.)

PS: The other factor is getting the right keywords in the paint layout itself. I know I made a few mistakes there as well.

Here’s a sample of my paint layout’s HTML (Yes. I know it’s tables. Emails suck - Thanks Outlook!!)

%begin_question_answer_2314089_q2_raw^neq:na%

		<tr valign="top">
			<th align="right">
				<strong>%question_name_2314089_q2%</strong>
			</th>
			<td>%question_answer_2314089_q2%</td>
		</tr>%end_question_answer_2314089_q2_raw%%begin_question_answer_2314089_q3_raw^neq:na%

		<tr valign="top">
			<th align="right">
				<strong>%question_name_2314089_q3%</strong>
			</th>
			<td>%question_answer_2314089_q3%</td>
		</tr>%end_question_answer_2314089_q3_raw%

(Adeel) #7

Thanks @evanwills for your help. It still doesn’t work for me so I am using the standard page option instead.


(Adeel) #8

Hi @Bart I am using the standard page asset and the keyword

%globals_asset_contents_raw:1237436^with_get:data={globals_post^rawurlencode}%

to format the web form submission data but there is an issue. My form is a multi page form and it only pushing the form’s last page data. I am using the following keyword to print the data in the email.

%nested_get_data^json_decode^index:q1237436:q1%

Is there a way I can push the data of all the form pages to the standard page?


(Bart Banda) #9

Hey, sorry for the late reply.

Multi-page forms make it a bit harder. Are you creating a form submission asset as part of the multi-step process? Then you should be able to use %form_submission_id^as_asset:asset_contents_paint_layout_id_2314291% method on the last confirmation step and get that in a hidden text field to get posted and then use %globals_get_post% ?

You could also look into using a trigger option using the form submission completed action and setting the value of the submission into a session var and potentially getting it that way using %globals_session_x%