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}}
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}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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