educaweb2/plugins/nextcloud_forms/templates/mako/nextcloud_forms.tmpl

104 lines
3.7 KiB
Cheetah

<form action="${endpoint}" id="form-${form['id']}">
<div id="form-${form['id']}-messages"></div>
% for question in form['questions']:
<div class="mb-3">
<label for="${question['formId'] }-question-${question['id']}"
class="form-label">${question['text']}
% if question['isRequired']:
*
% endif
</label>
% if question['type'] == "short":
<input type="text" class="form-control"
id="${question['formId'] }-question-${question['id']}"
aria-label="A short answer to question '${question['text']}'"
placeholder="Enter a short answer"
maxlength="4096" minlength="1"
% if question['isRequired']:
required
% endif
% elif question['type'] == "long":
<textarea class="form-control"
id="${question['formId']}-question-${question['id']}"
aria-label="A long answer to the question '${question['text']}'"
placeholder="Enter a long text"
maxlength="4096" minlength="1"
% if question['isRequired']:
required
% endif
rows="3">
</textarea>
% elif question['type'] == "multiple":
% for option in question['options']:
<div class="form-check">
<input class="form-check-input" type="checkbox" value=""
id="${question['formId']}-question-${question['id']}-answer-${option['id']}">
<label class="form-check-label"
for="${question['formId']}-question-${question['id']}-answer-${option['id']}">
${option['text']}
</label>
</div>
% endfor
% elif question['type'] == "multiple_unique":
% for option in question['options']:
<div class="form-check">
<input class="form-check-input" type="radio"
% if question['isRequired']:
required
% endif
name="${question['formId']}-question-${question['id']}"
id="${question['formId']}-question-${question['id']}-answer-${option['id']}">
<label class="form-check-label"
for="${question['formId']}-question-${question['id']}-answer-${option['id']}">
${option['text']}
</label>
</div>
% endfor
% elif question['type'] == "dropdown":
<select class="form-select"
% if question['isRequired']:
required
% endif
name="${question['text']}"
id="${question['formId']}-question-${question['id']}">
<option value=""> Select an option</option>
% for option in question['options']:
<option value="${option['id']}"
id="${question['formId']}-question-${question['id']}-answer-${option['id']}">
${option['text']}</option>
% endfor
</select>
% elif question['type'] == "date":
<input class="form-control" type="date" placeholder="Select a date"
% if question['isRequired']:
required
% endif
id="${question['formId']}-question-${question['id']}">
% elif question['type'] == "datetime":
<input class="form-control" type="datetime-local"
% if question['isRequired']:
required
% endif
placeholder="Select a date and time"
id="${question['formId']}-question-${question['id']}">
% else:
<div class="alert alert-danger" role="alert">
Unknown question type (question.type: ${question['type']})
</div>
% endif
</div>
% endfor
<button type="submit" aria-label="Submit the form"
class="btn btn-primary">Submit
</button>
</form>
<div style="display: none;" id="form-${form['id']}-success">
% if success_data:
${success_data}
% else:
Success
% endif
</div>