{{ define "content" }}

<div class="container">

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

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

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

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

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

    {{$options := ` { name: "class_id", id: "class_id", label: "Classe", title: "Seleziona la classe"}`}}
    {{template "select" dict "options" ($options|yaml) "data" (.Data|field "AllClasses") "selected" (.Data|field "SelectedClass") "update" $update "form" $form}}

    {{$options := ` { name: "tutor_id", id: "tutor_id", label: "Docente tutor", title: "Seleziona il docente tutor"}`}}
    {{template "select" dict "options" ($options|yaml) "data" (.Data|field "AllTeachers") "selected" (.Data|field "SelectedTeacher") "update" $update "form" $form}}

    {{$options := ` { name: "Handicap",id: "student_handicap",label: "Handicap (L. 104/92)",formClass: "form-group form-check" } `}}
    {{template "checkbox" dict "options" ($options|yaml) "value" (.Data|field "Handicap") "update" $update}}

    {{$options := ` { name: "DSA",id: "student_dsa",label: "DSA (L. 170/10)",formClass: "form-group form-check" } `}}
    {{template "checkbox" dict "options" ($options|yaml) "value" (.Data|field "DSA") "update" $update}}

    {{$options := ` { name: "BES",id: "student_bes",label: "BES (L. 170/10)",formClass: "form-group form-check" } `}}
    {{template "checkbox" dict "options" ($options|yaml) "value" (.Data|field "BES") "update" $update}}

    {{$options := ` { name: "operator_ids", id: "operator_ids", label: "Operatori", title: "Seleziona gli operatori associati allo studente", multiple: "true"}`}}
    {{template "select" dict "options" ($options|yaml) "data" (.Data|field "AllOperators") "selected" (.Data|field "SelectedOperator") "update" $update "form" $form}}

    {{$options := ` { name: "FatherLastname",id: "student_fatherlastname",label: "Cognome del padre",placeholder: "Cognome del padre",type: "text"} `}}
    {{template "input" dict "options" ($options|yaml) "value" (.Data|field "FatherLastname") "update" $update}}

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

    {{$options := ` { name: "FatherEmail",id: "student_fatheremail",label: "Email del padre",placeholder: "Email del padre",type: "text"} `}}
    {{template "input" dict "options" ($options|yaml) "value" (.Data|field "FatherEmail") "update" $update}}

    {{$options := ` { name: "MotherLastname",id: "student_motherlastname",label: "Cognome della madre",placeholder: "Cognome della madre",type: "text"} `}}
    {{template "input" dict "options" ($options|yaml) "value" (.Data|field "MotherLastname") "update" $update}}

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

    {{$options := ` { name: "MotherEmail",id: "student_motheremail",label: "Email della madre",placeholder: "Email della madre",type: "text"} `}}
    {{template "input" dict "options" ($options|yaml) "value" (.Data|field "MotherEmail") "update" $update}}

    {{$options := ` { name: "LegalGuardianLastname",id: "student_legalguardianlastname",label: "Cognome del tutore legale",placeholder: "Cognome del tutore legale",type: "text"} `}}
    {{template "input" dict "options" ($options|yaml) "value" (.Data|field "LegalGuardianLastname") "update" $update}}

    {{$options := ` { name: "LegalGuardianFirstname",id: "student_legalguardianfirstname",label: "Nome del tutore legale",placeholder: "Nome del tutore legale",type: "text"} `}}
    {{template "input" dict "options" ($options|yaml) "value" (.Data|field "LegalGuardianFirstname") "update" $update}}

    {{$options := ` { name: "LegalGuardianEmail",id: "student_legalguardianemail",label: "Email del tutore legale",placeholder: "Email del tutore legale",type: "text"} `}}
    {{template "input" dict "options" ($options|yaml) "value" (.Data|field "LegalGuardianEmail") "update" $update}}

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

{{ end }}
