{{ define "content" }}

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

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

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

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

    {{$options := ` { name: "Email",id: "office_email",label: "Email",placeholder: "Inserire l'indirizzo di posta elettronica",type: "email"} `}}
    {{template "input" dict "options" ($options|yaml) "value" (.Data|field "Email") "update" $update}}

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

{{ end }}
