Checkbox list selection - form submissions


(Innes Zenati) #1

Matrix Version:v5.5.2.3

Hi all, forms again! I am having trouble with a checkbox list selection (RLP declaration - #108220) appearing in my form submission emails. This is what I have but they are appearing as blank, I need to hide them if nothing is selected. Any help would be appreciated.

Primary contact details

Contact name : %response_108218_q1%
Contact email : %response_108218_q4%

Job title: %response_187574_q3%

Company name: %response_187574_q4%

Service requested

Service : %response_108217_q1%

%response_108220_q5^replace_keywords:notempty: RLP informal research session declaration: {response_108220_q5}%

%response_108220_q5^notempty: RLP informal research session declaration: {response_108220_q5}%

Users: %response_108218_q3%

Thanks
Innes


#2

Hi @innesz
I think neither of those options work because Matrix wraps a <p> tag around the keyword modifier, not around the result.

The workaround I’ve identified is to edit the email body and wrap your modifier in a <div> tag, adding the <p> tag within the modifier result.
The email will still include the <div> tag but empty divs collapse to zero-height.

Your source should be similar to:

<p><strong>Service</strong>: %response_908933_q1%</p>
<div>
  %response_908933_q2^notempty:<p><strong>RLP declaration</strong>: {response_908933_q2}</p>%
</div>
<p><strong>User</strong>: %response_908933_q3%</p>

Hope this helps.
Cheers.


#3

Just to satisfy my curiosity I also tried another approach using styles.

Obviously, using a style tag won’t work everywhere:

Inline styles work:

<p><strong>Service</strong>: %response_908933_q1%</p>
<p style="display:%response_908933_q2^lowercase^contains:yes:block:none%; color:#%response_908933_q2^lowercase^contains:yes:f00:000%;"><strong>RLP declaration</strong>: %response_908933_q2%
</p>
<p><strong>User</strong>: %response_908933_q3%
</p>

IMHO, this approach is more trouble than it’s worth.
It seems display:none doesn’t work everywhere and if the checkbox value changes one must remember to update the modifier. Harder to maintain for multiple instances.

One could use this approach for conditional styling (see the color usage) though.


(Innes Zenati) #4

Superb @np81 thanks for taking the time to look into this. Very much appreciated, will give this a go now and get back to you.

Cheers
Innes


(Innes Zenati) #5

Hey, so I have tried that but I am still getting the same result in the email submission data. This is what i have and looks fine:

%response_108220_q5^replace_keywords:notempty:

RLP informal research session declaration: {response_108220_q5}

%


#6

Seems to be fine. :thinking:
Can you share your email body source? You can add code in a comment by wrapping in (triple) backticks.

I’d only run a test with your second option - notempty without replace_keywords. Does that fail too?

I’ve also just realised I am on a different version (6.9x), so it’s possible a bug/feature has impacted the behaviour.
And, I haven’t tried this but, a third option might be to send the email as plain text.


(Innes Zenati) #7

Hi, this is what I have in the email body:

Primary contact details

Contact name: %response_108218_q1%
Contact email: %response_108218_q4%

Job title: %response_187574_q3%

Company name: %response_187574_q4%

%response_108220_q5^replace_keywords:notempty:

RLP informal research session declaration: {response_108220_q5}

%

Service requested

Service: %response_108217_q1%

Users: %response_108218_q3%


#8

Hi @innesz, this still looks like the output of the WYSIWYG editor, and may be the issue. You need to edit the HTML source.

See Viewing the HTML Source Code. The Toggle Source View button is <>.


(Innes Zenati) #9

Hi @np81, yeah I did change this in the edit source function as its now wrapped in the relevant div you had suggested. I will copy the source code for you as it changed it to plain text when I copied it yesterday.

Cheers


(Innes Zenati) #10
<div>
%response_108220_q5^replace_keywords:notempty: 
<p><strong style="border: 0px">RLP informal research session declaration:</strong> {response_108220_q5}
</p>
%

#11

The closing div is missing. But, assuming you’ve just missed copying it here, that looks fine to me.
Might just be a bug/missing feature for your version.


(Bart Banda) #12

You would need to escape some characters in the notempty HTML, like : and \ as I’m pretty sure those are breaking the keyword from replacing.

Also worth trying to put it all on one line in case there’s a bug with newlines within the keyword in that version.


(Innes Zenati) #13

Thanks Bart, was able to get this implemented with some help from Squiz dev support. Working like a treat now.