success and error message not working
-
I am trying to use custom form but it doesn’t display error or success messages. Here is the code I am using:
[msdyncrm_twig]
{% form entity=”lead” mode=”create” required=[“firstname”, “companyname”, “mobilephone”] message={ “success”: “Form submitted.”, “error”: “Submission failed.” } %}
<form method=”POST”>
<input name=”firstname” type=”text” placeholder=”First Name” class=”customfeild”>
<input name=”companyname” type=”tel” placeholder=”Company” class=”customfeild”>
<input name=”mobilephone” type=”text” placeholder=”Mobile Number” class=”customfeild”>
<button class=”button custombutton” type=”Submit”>Text me a demo</button>
<input type=”hidden” name=”_key” value=”{{form.key}}”>
</form>
{% endform %}[/msdyncrm_twig]
-
Hi @abhijeetub
property message does not exist, you’re probably after messages, i.e.
messages={ "success": "Form submitted.", "error": "Submission failed." }HTH
Hi @alexacrm
My bad. I fixed it, it still doesn’t work. And will it hide the form as well?Hi @abhijeetub
since you’re rendering the form yourself, you’re in charge of the messages and how and when they appear. You can use templates/twig/form.twig as a template, e.g.
{% if form.submission and form.status %} <div class="row"> <div class="col-12"> <div class="alert alert-success"> {{ form.parameters.messages.success }} </div> </div> </div> {% elseif form.submission and (not form.status) %} <div class="row"> <div class="col-12"> <div class="alert alert-danger"> {{ form.parameters.messages.error }} </div> </div> </div> {% endif %} <form ...HTH
GeorgeThank you. That works.
Hi @alexacrm
How do I disable the form or the button when I click on submit button?
@abhijeetub
we don’t provide any specific code for what you’re asking. Any standard js approach should work, see https://stackoverflow.com/questions/15529836/simplest-way-to-disable-button-on-submission-of-a-formThanks
George
The topic ‘success and error message not working’ is closed to new replies.