{{ define "content" }}

<div class="container">

  {{$update := .Options.Get "update"}}

  {{if $update}}
  {{template "breadcrumb" toSlice "Classi" (all "Class") (.Data|string) (.Data.ID|show "Class") "Aggiorna" "current"}}
  {{else}}
  {{template "breadcrumb" toSlice "Classi" (all "Class") "Aggiungi" "current"}}
  {{end}}
  
  {{template "add_update_header" dict "update" $update "addTitle" "Crea nuova classe" "updateTitle" (printf "Aggiorna la classe %s" (.Data|string))}}

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

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

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

    {{$options := ` { name: "Year",id: "class_year",label: "Anno",placeholder: "",type: "number",required: "true"} `}}
    {{template "input" dict "options" ($options|yaml) "value" (.Data|field "Year") "update" $update}}

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

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

    {{$options := ` { name: "coordinator_id", id: "coordinator_id", label: "Coordinatore", title: "Seleziona il coordinatore"}`}}
    {{template "select" dict "options" ($options|yaml) "data" (.Data|field "AllTeachers") "selected" (.Data|field "SelectedCoordinator") "update" $update "form" $form}}

    {{$options := ` { name: "minuter_id", id: "minuter_id", label: "Verbalizzante", title: "Seleziona il verbalizzante"}`}}
    {{template "select" dict "options" ($options|yaml) "data" (.Data|field "AllTeachers") "selected" (.Data|field "SelectedMinuter") "update" $update "form" $form}}

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

{{ end }}



