oef/templates/answers_add_update.html.tpl
2019-11-14 12:55:22 +01:00

37 lines
1.7 KiB
Smarty

{{ define "content" }}
<div class="container">
{{$update := .Options.Get "update"}}
{{if $update}}
{{template "breadcrumb" toSlice "Risposte" (all "Answer") (.Data|string|trim) (.Data.ID|show "Answer") "Aggiorna" "current"}}
{{else}}
{{template "breadcrumb" toSlice "Risposte" (all "Answer") "Aggiungi" "current"}}
{{end}}
{{template "add_update_header" dict "update" $update "addTitle" "Crea nuova risposta" "updateTitle" (printf "Aggiorna risposta %s" (.Data|string|trim))}}
{{$form := "form_add_update"}}
<form
class="needs-validation"
action="{{if $update}}{{.Data.ID|update "Answer"}}{{else}}{{create "Answer"}}{{end}}"
method="POST"
role="form"
id={{$form}}>
{{$options := ` { name: "Text",id: "answer_text",label: "Testo della risposta",placeholder: "Inserire il testo della risposta",type: "text",required: "true"} `}}
{{template "input" dict "options" ($options|yaml) "value" (.Data|field "Text") "update" $update}}
{{$options := ` { name: "question_id", id: "question_id", label: "Domanda relativa a questa risposta", title: "Seleziona la domanda"}`}}
{{template "select" dict "options" ($options|yaml) "data" (.Data|field "AllQuestions") "selected" (.Data|field "Selected") "update" $update "form" $form}}
{{$options := ` { name: "Correct",id: "answer_correct",label: "La risposta è corretta",placeholder: "",type: "checkbox",formClass: "form-check form-check-inline"} `}}
{{template "checkbox" dict "options" ($options|yaml) "value" (.Data|field "Correct") "update" $update}}
{{$options := ` { cancelTitle: "Annulla", saveTitle: "Salva", model: "Answer"} `}}
{{template "submit_cancel_buttons" dict "options" ($options|yaml) "id" (.Data|field "ID") "update" $update}}
</form>
</div>
{{ end }}