Email Form
ExpressionEngine 2, ExpressionEngine 3, ExpressionEngine 4
Back to this add-on's main page
View Other Add-ons From Rein de Vries
custom errors?
General (Resolved)
bjp
|
Posted: 01 October 2014 07:22 PM |
|
|
|
Is it possible to define custom errors for input fields? Thanks
|
|
|
Reinos
|
Posted: 03 October 2014 09:28 AM |
# 1
|
|
Developer
|
You can do something like this
{if body:error != ''}this is a custom error{/if}
{exp:email_form:form required_fields="body|inputfield" error_msg:body="is nodig" } <!-- You can declare as many field you wish to use inside your form. just be creative. --> {if body:error != ''}this is a custom error{/if} <textarea name="body">{body:value}</textarea>
{if inputfield:error != ''}this is yet another custom error{/if} <input type="text" name="inputfield" value="{inputfield:value}" /> <input type="submit"/>
{email_template to:name="John Doe" to:email="test@example.nl" from:name="William Doe" from:email="test@no-example.com" subject="Test email" } This email is sent to {to:name}. The following field, that are declared inside the form can be used inside this template. {inputfield} {body} {/email_template}
{/exp:email_form:form}
|
|
|
bjp
|
Posted: 05 October 2014 07:08 AM |
# 2
|
|
|
Works well, thanks!
|
|
|
Reinos
|
Posted: 05 October 2014 08:12 AM |
# 3
|
|
Developer
|
No problem.
* feel free to review the addon.
Best,
Rein
|
|
|
r_tait
|
Posted: 09 January 2015 07:40 PM |
# 4
|
|
|
Not working for me with this simple form please help! the “has-error” never shows on submitting blank:
{exp:email_form:form required_fields="name"} <div class="row"> <div class="col-xs-6"> <div class="form-group{if name:error != ''} has-error{/if}"> <label for="name">{exp:transcribe:replace name="name"} <span class="light-green">*</span></label>
<input type="text" class="form-control" name="name" id="name" placeholder="{exp:transcribe:replace name='name'}"/> </div>
<div class="form-group"> <button type="submit" class="btn btn-success">{exp:transcribe:replace name="submit"}</button>
<span class="green">{exp:transcribe:replace name="required_fields"}</span> </div> </div> </div>
{email_template to:name="John Doe" to:email="test@test.com" from:name="William Doe" from:email="no-reply@test.com" subject="Test email" } {name} {/email_template} {/exp:email_form:form}
|
|
|
Reinos
|
Posted: 15 January 2015 09:22 AM |
# 5
|
|
Developer
|
What if you quote the if like this:
{if ‘{name:error}’ != ‘’} has-error{/if}
|
|
|
r_tait
|
Posted: 15 January 2015 10:19 PM |
# 6
|
|
|
That causes the IF statement to not work at all it outputs: <div class=“form-group’ != ‘’} has-error”>
|
|
|