{{ define "content" }}

<div class="container">
  
  {{$update := .Options.Get "update"}}

  {{if $update}}
  {{template "breadcrumb" toSlice "Gruppi" (all "Group") (.Data|string) (.Data.ID|show "Group") "Aggiorna" "current"}}
  {{else}}
  {{template "breadcrumb" toSlice "Gruppi" (all "Group") "Aggiungi" "current"}}
  {{end}}
  
  {{template "add_update_header" dict "update" $update "addTitle" "Crea nuovo gruppo" "updateTitle" (printf "Aggiorna gruppo %s" (.Data|string))}}

  {{$form := "form_groups_add_update"}}
  <form
    class="needs-validation"
    action="{{if $update}}{{.Data.ID|update "Group"}}{{else}}{{create "Group"}}{{end}}"
    method="POST"
    role="form"
    id={{$form}}>

    {{$options := ` { name: "Name",id: "group_name",label: "Nome",placeholder: "Nome",type: "text",required: "true"} `}}
    {{template "input" dict "options" ($options|yaml) "value" (.Data|field "Name") "update" $update}}

    {{$options := ` { name: "Query",id: "group_query",label: "Stringa di popolamento",placeholder: "surname:*",type: "text"} `}}
    {{template "input" dict "options" ($options|yaml) "value" (.Data|field "Query") "update" $update}}

    {{$options := ` { name: "teacher_ids", id: "teacher_ids", label: "Docenti", title: "Seleziona i docenti", multiple: "true"}`}}
    {{template "select" dict "options" ($options|yaml) "data" (.Data|field "AllTeachers") "selected" (.Data|field "SelectedTeacher") "update" $update "form" $form}}

    {{ $options := ` { cancelTitle: "Annulla", saveTitle: "Salva", model: "Group"} ` }}
    {{template "submit_cancel_buttons" dict "options" ($options|yaml) "id" (.Data|field "ID") "update" $update}}  
  </form>
  
</div>

{{ end }}
