{{ define "content" }}

<div class="container">

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

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

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

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

    {{$options := ` { name: "department_id", id: "department_id", label: "Dipartimento", title: "Seleziona il dipartimento"}`}}
    {{template "select" dict "options" ($options|yaml) "data" (.Data|field "AllDepartments") "selected" (.Data|field "Selected") "update" $update "form" $form}}
    
    {{ $options := ` { cancelTitle: "Annulla", saveTitle: "Salva", model: "Subject"} ` }}
    {{template "submit_cancel_buttons" dict "options" ($options|yaml) "id" (.Data|field "ID") "update" $update}}
  
  </form>
  
</div>

{{ end }}
