1

Added new input field in default Contact form :

/magento_root/app/design/frontend/VENDER_NAME/YOUR_THEME/Magento_Contact/templates/form.phtml

<input title="Test Id" name="testid" id="testid" value=""/>

Created new custom template and assigned it to Contact Form with below code.

{{trans "Test Id: %testid" testid=$data.testid}}
{{trans "Name: %name" name=$data.name}}
{{trans "Email: %email" email=$data.email}}
{{trans "Phone Number: %telephone" telephone=$data.telephone}}
{{trans "Comment: %comment" comment=$data.comment}}

I tried to add condition like :

{{depend $data.testid}}
 {{trans "Test Id: %testid" testid=$data.testid}}
{{/depend}}

But this is not working.

If $data.testid is empty then I don't want to print that line :

{{trans "Test Id: %testid" testid=$data.testid}}
asked Nov 30, 2017 at 13:46

1 Answer 1

1

No way found to add condition explained in question, I did it using following way:

Created 2 different email templates and then I am going to assign a template depending on condition.

Inside controller, I am checking that if $testid is not empty then I am assigning a email template with

{{trans "Test Id: %testid" testid=$data.testid}}
{{trans "Name: %name" name=$data.name}}
{{trans "Email: %email" email=$data.email}}
{{trans "Phone Number: %telephone" telephone=$data.telephone}}
{{trans "Comment: %comment" comment=$data.comment}}

otherwise I am assigning another which is,

{{trans "Name: %name" name=$data.name}}
{{trans "Email: %email" email=$data.email}}
{{trans "Phone Number: %telephone" telephone=$data.telephone}}
{{trans "Comment: %comment" comment=$data.comment}}
answered Jan 30, 2018 at 8:59

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.