oef/templates/participants_add_update.html.tpl
2019-12-09 08:27:46 +01:00

78 lines
3 KiB
Smarty

{{ define "content" }}
{{$isAdmin := .Claims|isAdmin}}
{{$isSchool := .Claims|isSchool}}
<div class="container">
{{$update := .Options.Get "update"}}
{{if $update}}
{{template "breadcrumb" toSlice "Participanti" (all "Participant") (.Data|string) (.Data.ID|show "Participant") "Aggiorna" "current"}}
{{else}}
{{template "breadcrumb" toSlice "Participanti" (all "Participant") "Aggiungi" "current"}}
{{end}}
{{template "add_update_header" dict "update" $update "addTitle" "Crea nuovo partecipante" "updateTitle" (printf "Aggiorna partecipante %s" (.Data|string))}}
{{$form := "form_add_update"}}
<form
class="needs-validation"
action="{{if $update}}{{.Data.ID|update "Participant"}}{{else}}{{create "Participant"}}{{end}}"
method="POST"
role="form"
id={{$form}}>
<div class="form-row">
<div class="col">
{{$options := ` { name: "Firstname",id: "participant_firstname",label: "Nome del partecipante",placeholder: "Inserire il nome del partecipante",type: "text",required: "true"} `}}
{{template "input" dict "options" ($options|yaml) "value" (.Data|field "Firstname") "update" $update}}
</div>
<div class="col">
{{$options := ` { name: "Lastname",id: "participant_lastname",label: "Cognome del partecipante",placeholder: "Inserire il cognome del partecipante",type: "text",required: "true"} `}}
{{template "input" dict "options" ($options|yaml) "value" (.Data|field "Lastname") "update" $update}}
</div>
</div>
{{$options := `
name: "FiscalCode"
id: "participant_fiscalcode"
label: "Codice fiscale del partecipante"
placeholder: "Inserire il codice fiscale"
type: "text"
inputClass: "form-control uppercase"
required: "true" `}}
{{template "input" dict "options" ($options|yaml) "value" (.Data|field "FiscalCode") "update" $update}}
{{$options := `
name: "category_id"
id: "category_id"
label: "Categoria del partecipante"
title: "Seleziona la categoria"
required: "true"
`}}
{{template "select" dict "options" ($options|yaml) "data" (.Data|field "AllCategories") "selected" (.Data|field "SelectedCategory") "update" $update "form" $form}}
{{if $isAdmin}}
{{$options := ` { name: "school_id", id: "school_id", label: "Scuola del partecipante", title: "Seleziona la scuola"}`}}
{{template "select" dict "options" ($options|yaml) "data" (.Data|field "AllSchools") "selected" (.Data|field "SelectedSchool") "update" $update "form" $form}}
{{$options := `
name: "contest_ids"
id: "contest_ids"
label: "Gare a cui il partecipante è iscritto"
title: "Seleziona le gare"
multiple: "true"
required: "true"
`}}
{{template "select" dict "options" ($options|yaml) "data" (.Data|field "AllContests") "selected" (.Data|field "SelectedContest") "update" $update "form" $form}}
{{end}}
{{$options := ` { cancelTitle: "Annulla", saveTitle: "Salva", model: "Participant" } `}}
{{template "submit_cancel_buttons" dict "options" ($options|yaml) "id" (.Data|field "ID") "update" $update}}
</form>
</div>
{{ end }}