= form_for [:admin, @user], html: { role: 'form', data: { validated: true } } do |f|
  .form-group
    = f.label :username
    = f.text_field :username, class: 'form-control', placeholder: 'Entrez le nom du membre.'
    %span.help-block.with-errors
  .form-group
    = f.label :email
    = f.text_field :email, class: 'form-control', placeholder: "Entrez l'e-mail du membre."
  .form-group
    = f.label :phone
    = f.text_field :phone, class: 'form-control', placeholder: "Entrez le téléphone du membre."
    %span.help-block.with-errors
  .form-group
    = f.label :password do
      = User.human_attribute_name(:password)
      %small
        %span.text-muted –
        = link_to '#', id: 'generate-password' do
          %i.fa.fa-refresh
          Générer automatiquement
    = f.text_field :password, class: 'form-control', placeholder: @user.id? ? "Entrez le nouveau mot de passe. Laisser vide n'entraînera aucun changement." : "Entrez le mot de passe."
    %span.help-block.with-errors
  - if @user.new_record?
    = f.hidden_field :password_confirmation
  - else
    .form-group
      = f.label :password_confirmation
      = f.text_field :password_confirmation, class: 'form-control', placeholder: "Entrez la confirmation du mot de passe."
      %span.help-block.with-errors
  - if @user.new_record?
    .form-group.admin
      = f.label :locale
      = label_tag nil, class: 'radio' do
        = f.radio_button :locale, :fr, checked: true
        Français
      = label_tag nil, class: 'radio' do
        = f.radio_button :locale, :en
        Anglais
  .form-group.admin
    = f.label :admin
    = label_tag nil, class: 'radio' do
      = f.radio_button :admin, true
      Oui
    = label_tag nil, class: 'radio' do
      = f.radio_button :admin, false
      Non
    %span.help-block.with-errors
  .form-group
    = f.label :group_ids do
      = User.human_attribute_name(:group_ids)
      %small
        %span.text-muted –
        = link_to 'Tous', '#', id: 'check-all'
        %span.text-muted –
        = link_to 'Aucun', '#', id: 'check-none'
    %p.help-block Sélectionnez les groupes auxquels appartient ce membre.
    .row
      - Group.all.each do |group|
        .col-sm-3
          = label_tag nil, class: 'checkbox-inline' do
            = check_box_tag "user[group_ids][]", group.id, @user.group_ids.include?(group.id)
            = group.name
    %span.help-block.with-errors
  %br
  .form-group
    = submit_tag t('links.submit'), class: 'btn btn-primary'
    = link_to t('links.cancel'), admin_users_path, class: 'btn btn-default'