oef/templates/responses_add_update.html.tpl

56 lines
1.7 KiB
Smarty
Raw Normal View History

2019-11-18 17:04:07 +01:00
{{ define "content" }}
<div class="container">
{{$admin := (.Claims|isAdmin)}}
{{$update := .Options.Get "update"}}
{{if $admin}}
{{if $update}}
{{template "breadcrumb" toSlice "Responses" (all "Response") (.Data|string) (.Data.ID|show "Response") "Aggiorna" "current"}}
{{else}}
{{template "breadcrumb" toSlice "Responses" (all "Response") "Aggiungi" "current"}}
{{end}}
{{end}}
{{template "add_update_header" dict "update" $update "addTitle" "Rispondi al questionario" "updateTitle" (printf "Aggiorna le tue risposte %s" (.Data|string))}}
{{$form := "form_add_update"}}
<form
class="needs-validation"
action="{{if $update}}{{.Data.ID|update "Response"}}{{else}}{{create "Response"}}{{end}}"
method="POST"
role="form"
id={{$form}}>
{{range $question := .Data.Questions}}
<div class="form-group p-3">
<p class="lead">{{$question.Text}}</p>
{{range $answer := $question.Answers}}
<div class="form-check">
<input class="form-check-input" type="radio" name="question_{{$question.ID}}" id="answer_{{$answer.ID}}" value="{{$answer.ID}}">
<label class="form-check-label" for="answer_{{$answer.ID}}">
{{$answer}}
</label>
</div>
{{end}}
</div>
{{end}}
{{if $admin}}
{{$options := ` { cancelTitle: "Annulla", saveTitle: "Salva", model: "Response" } `}}
{{template "submit_cancel_buttons" dict "options" ($options|yaml) "id" (.Data|field "ID") "update" $update}}
{{else}}
{{$options := ` { saveTitle: "Invia le risposte", model: "Response" } `}}
{{template "submit_cancel_buttons" dict "options" ($options|yaml) "id" (.Data|field "ID") "update" $update}}
{{end}}
</form>
</div>
{{ end }}