If I have a checkbox on the contact form how do I pull these values into the email template.

My form looks like

    <label for="telephone">Contact Method</label>
    <div class="input-box">
       <input type="checkbox" name="contact_method[]" value="Telephone"> Telephone<br>
       <input type="checkbox" name="contact_method[]" value="Email"> Email<br>

However if I do

Contact Method: {{var data.contact_method}}

The value comes out as array

  • Did you try changing the name to contact_method instead of contact_method[] ? Feb 22, 2016 at 13:15
  • Yes I tried {{var data.contact_method[]}} and {{var data.contact_method[0]}} but both come out blank
    – Goose84
    Feb 22, 2016 at 13:18
  • In your form "<input type="checkbox" name="contact_method[]" value="Telephone"> Telephone<br>" remove the [] from contact_method
    – seb
    Feb 22, 2016 at 13:19
  • If I remove the [] then only 1 option can be selected
    – Goose84
    Feb 22, 2016 at 13:20
  • I didn't notice you were using checkboxes. You should not be using the same name in case of checkboxes, try using two different names and then use 2 lines in your email template. Feb 22, 2016 at 13:22

1 Answer 1


Magento doesn't allow to use array in email variable.So change checkbox html as below.

<input type="checkbox" name="contact_method_tel" value="Telephone"> Telephone<br>
<input type="checkbox" name="contact_method_email" value="Email"> Email<br>

Now use depend condition (can also use if/else) in email template based on below checkbox selection as below.

{{depend data.contact_method_tel}}
    {{var data.contact_method_tel}} //show telephone if checked
{{depend data.contact_method_email}}
    {{var data.contact_method_email}} //show email if checked

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.