<p class="notice" id="adduser-error" style="font-weight: bold"></p>

<form method="POST" id="adduser-form">
<p>{"Name"}:<br /><input type="text" name="name" size="40" value="{{ name }}" />
<span class="notice" id="name-notice">{"You must enter a name."}</span></p>
<p>{"Email"}:<br /><input type="text" name="email" size="40" value="{{ email }}" />
<span class="notice" id="email-notice">{"You must enter an email address."}</span></p>
<p>{"Password"}:<br /><input type="password" name="password" size="20" value="{{ password }}" />
<span class="notice" id="password-notice">{"You must enter a password."}</span></p>
<p>{"Verify password"}:<br /><input type="password" name="verify_pass" size="20" value="{{ verify_pass }}" />
<span class="notice" id="verify_pass-notice">{"Your password doesn't match."}</span></p>

{% if User::require_acl ('user/edit_roles') %}
	<p>{"Member role"}:<br />
	<select name="type">
	{% foreach types %}
		<option value="{{ loop_value }}"{% if type === $data->loop_value %} selected {% end %}>{{ loop_value|ucfirst }}</option>
	{% end %}
	</select></p>
{% else %}
	<input type="hidden" name="type" value="{{type}}" />
{% end %}

{! admin/util/extended?extends=User&modal=true !}

<p>
	<input type="submit" value="{"Add Member"}" />&nbsp;
	<a href="javascript:void(0)" id="adduser-cancel">{"Cancel"}</a>
</p>

<input type="hidden" name="_token_" value="{{csrf_token}}" />

</form>

<script type="text/javascript">
$(function () {
	$('#adduser-form').verify_values ({
		handler: 'user/add',
		callback: function (failed) {
			// highlight the failed elements
			for (var i = 0; i < failed.length; i++) {
				$('#' + failed[i] + '-notice').show ();
			}
		},
		reset: function (fields) {
			for (var i = 0; i < fields.length; i++) {
				$('#' + fields[i] + '-notice').hide ();
			}
		}
	});
	{% foreach failed %}
	$('#{{ loop_value }}-notice').show ();
	{% end %}
});
</script>
