Hi I have user registration form with multiple custom fields. They all work fine except for the field I have as a checkbox. It returns an error of 'my-field' is invalid. Any ideas anyone? code below (field in question is towards the bottom)...
<form method="post" accept-charset="UTF-8" class="login-form">
{{ getCsrfInput() }}
<input type="hidden" name="action" value="users/saveUser">
<input type="hidden" name="redirect" value="{{ url('collection/') }}">
<h3>Register</h3>
<p>To browse our collection please register your information below.</p>
<p>Already registered? <a href="#login-modal" class="toggle-modal-trigger">Login</a>.</p>
{{ entry.contentBeforeForm }}
{% macro errorList(errors) %}
{% if errors %}
<ul class="errors">
{% for error in errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
{% endmacro %}
{% from _self import errorList %}
<h4><label for="firstName">First name</label></h4>
<input id="firstName" type="text" name="firstName" {%- if account is defined %} value="{{ account.firstName }}"{% endif %} placeholder="First name">
{{ account is defined and account ? errorList(account.getErrors('firstName')) }}
<h4><label for="lastName">Last name</label></h4>
<input id="lastName" type="text" name="lastName" {%- if account is defined %} value="{{ account.lastName }}"{% endif %} placeholder="Last name">
{{ account is defined and account ? errorList(account.getErrors('lastName')) }}
<h4><label for="company">Company</label></h4>
<input id="company" type="text" name="fields[company]" {%- if account is defined %} value="{{ account.company }}"{% endif %} placeholder="Company">
{{ account is defined and account ? errorList(account.getErrors('company')) }}
<h4><label for="phone">Phone</label></h4>
<input id="phone" type="text" name="fields[phone]" {%- if account is defined %} value="{{ account.phone }}"{% endif %} placeholder="Phone">
{{ account is defined and account ? errorList(account.getErrors('phone')) }}
<h4><label for="username">Username</label></h4>
<input id="username" type="text" name="username" {%- if account is defined %} value="{{ account.username }}"{% endif -%} placeholder="Username">
{% if account is defined %}
{{ errorList(account.getErrors('username')) }}
{% endif %}
<h4><label for="email">Email</label></h4>
<input id="email" type="text" name="email" {%- if account is defined %} value="{{ account.email }}"{% endif %} placeholder="Email">
{% if account is defined %}
{{ errorList(account.getErrors('email')) }}
{% endif %}
<h4><label for="password">Password</label></h4>
<input id="password" type="password" name="password">
{% if account is defined %}
{{ errorList(account.getErrors('password')) }}
{% endif %}
{# HERE IS THE FIELD CAUSING THE ERROR #}
<label>
<input type="checkbox" id="termsAgreement" name="fields[termsAgreement]" {%- if account is defined %}value="1" checked{% endif %}>
I agree to terms and conditions above
</label>
{{ account is defined and account ? errorList(account.getErrors('termsAgreement')) }}
<input type="submit" value="Register">
</form>
1/true
or0/false
. Currently you are sending anull
value if the field is not checked as well