formidable/internal/server/template/blocks/form_input_array.html.tmpl

38 lines
1.6 KiB
Cheetah

{{ define "form_input_array" }}
{{ $root := . }}
{{ $fullProperty := getFullProperty .Parent .Property }}
{{ $values := getValue .Values $fullProperty }}
<table width="100%">
<tbody>
{{ range $index, $value := $values }}
{{ $itemFullProperty := printf "%s/%d" $fullProperty $index }}
{{ $itemProperty := printf "%d" $index }}
{{ $itemSchema := getItemSchema $root.Schema }}
{{ $formItemData := formItemData $root $itemProperty $itemSchema }}
<tr>
{{ template "form_row" $formItemData }}
</tr>
<tr>
<td></td>
<td colspan="2">
<input type="submit"
class="bg-red-600 text-white mb-2 px-3 py-1 rounded-md text-sm font-medium hover:bg-red-700 transition duration-300"
name="del:{{ $fullProperty }}/{{$index}}"
value="Remove" />
<hr />
</td>
</tr>
{{end}}
<tr>
<td colspan="2"></td>
<td align="right">
<input
class="bg-blue-500 text-white mb-2 mt-2 px-3 py-1 rounded-md text-sm font-medium hover:bg-blue-700 transition duration-300"
type="submit"
name="add:{{ $fullProperty }}/-"
value="Add" />
</td>
</tr>
</tbody>
</table>
{{ end }}