{ifset $errors}
<div class="ink-alert basic error" role="alert">
  {reset( $errors )[0]}
</div>
{/ifset}
{import forms.html}
<div class="column-group">
  <div class="xlarge-50 large-50 medium-60 small-100 tiny-100">
    <form name="user_form" id="user_form" action="{$action}" method="POST" enctype="multipart/form-data" class="ink-form">
      <div class="control-group{ifset $errors['username']} validation warning{/ifset}">
	<label for="user_username">{_'username'}</label>
	<div class="control">
	  {include input, name => 'user[username]', value => ($user->username), maxlength => 100, required => true, autofocus => true }
	</div>
      </div>
      <div class="control-group{ifset $errors['email']} validation warning{/ifset}">
	<label for="user_email">{_'email'}</label>
	<div class="control">
	  {include input, name => 'user[email]', value => ($user->email), 'type' => 'email', maxlength => 100, required => true }
	</div>
      </div>
      <div class="control-group{ifset $errors['password']} validation warning{/ifset}">
	<label for="user_password">{_'password'}</label>
	<div class="control">
	  {include input, name => 'user[password]', 'type' => 'password',  maxlength => 100 }
	</div>
      </div>
      <div class="control-group{ifset $errors['password_confirmation']} validation warning{/ifset}">
	<label for="user_password_confirmation">{_'password_confirmation'}</label>
	<div class="control">
	  {include input, name => 'user[password_confirmation]', 'type' => 'password', maxlength => 100 }
	</div>
      </div>
      <div class="control-group">
	<label for="user_status">{_}status{/_}</label>
	<div class="control">
	  {var $statuses = ['inactive'|translate, 'active'|translate]}
	  {include select, name => 'user[status]', value => ($user->status), options => $statuses}
	</div>
      </div>
      <div class="control-group">
	<p class="label">{_}roles{/_}</p>
	<ul class="control unstyled">
	  {foreach models\Role::findAll() as $role}
	  <li>{include input, name => ('roles[' . $role->role_id . ']'), value => 1, 'type' => 'checkbox', checked => ($user->hasRole( $role->name ))}<label for="{('roles_' . $role->role_id)}">{_}{$role->name}{/_}</label></li>
	  {/foreach}
	</ul>
      </div>
      {include input, name => 'save', value => ( 'save'|translate ), 'type' => 'submit', class => 'ink-button green' }
      {var $confirm = ('confirm_delete_user'|translate:$user->username)}
      {if !$user->isNewRecord()}<a href="{=BASE_URL}user/delete/{$user->user_id}" onclick="return confirm('{$confirm|noescape}');" class="ink-button red">{_}delete{/_}</a>{/if}{_'or'} <a href="{=BASE_URL}user/list">{('cancel'|translate|lower)}</a>
    </form>
  </div>
</div>
