bunteshaus.de/themes/buha/layouts/partials/layout/generator/form.html

141 lines
8.2 KiB
HTML
Raw Normal View History

2022-04-06 17:51:02 +02:00
{{ $pageform := (index .context.Page.Params.forms .form) }}
{{ $group := slice }}
2022-04-08 17:21:11 +02:00
{{ $divide := .context.Page.Params.divide }}
2022-04-06 17:51:02 +02:00
<form id="myform">
{{ range $pageform.fields }}
2022-04-08 17:21:11 +02:00
{{ $title := .title }}
{{ $name := $title }}
{{ if .name }}
{{ $name = .name }}
{{ end }}
2022-04-06 17:51:02 +02:00
{{ if and .group (not (in $group .group))}}
<div class="margin_top_1rem">
2022-04-08 13:22:50 +02:00
{{ if i18n (singularize .group) }}{{ i18n (singularize .group) }}{{ else }}{{ humanize .group }}{{ end }}
2022-04-10 11:00:14 +02:00
{{ partial "layout/generator/expand" (dict "name" (printf "%sgroup" .group)) }}
2022-04-06 17:51:02 +02:00
</div>
{{ $group = $group | append .group }}
{{ end }}
2022-05-10 04:16:08 +02:00
{{ if eq .input_type "buttons" }}
<button onclick="button({{ .title }})" type="button" value="{{ .title }}">{{ .name }}</button>
{{ else if eq .input_type "title" }}
2022-04-08 17:21:11 +02:00
<h3 {{ if .group }}class="visibleIf margin_left_1rem" data-visibleif-rule="{{ .group }}group == 'true'"{{ end }}>{{- $name -}}{{- if .required -}}{{- " *" -}}{{- end -}}</h3>
2022-04-06 17:51:02 +02:00
{{ else if eq .input_type "textarea" }}
2022-05-09 23:01:43 +02:00
<div class="w100 {{ if .group }} visibleIf margin_left_1rem" data-visibleif-rule="{{ .group }}group == 'true' {{ end }}">
<label class="w100 {{ if $pageform.names }}sr-only{{ end }}" for="{{ .title }}">{{- $name -}}{{- if .required -}}{{- " *" -}}{{- end -}}</label>
<textarea class="w100" name="{{ .title }}" id="{{ .title }}" rows="10" {{ if .placeholder }}placeholder="{{ .placeholder }}"{{ end }}></textarea>
2022-04-06 17:51:02 +02:00
</div>
{{ else if eq .input_type "radio" }}
2022-04-06 19:06:41 +02:00
<div class="radio {{- if .group }} visibleIf margin_left_1rem" data-visibleif-rule="{{ .group }}group == 'true'{{ end }}">
2022-04-08 17:21:11 +02:00
<label><input type="radio" name="{{ .title }}" id="{{ .title }}" value="{{ .name }}" {{ .Scratch.Get "requiredtext" }}>{{- $name -}}{{- if .required -}}{{- " *" -}}{{- end -}}</label>
2022-04-06 17:51:02 +02:00
</div>
{{ else if eq .input_type "checkbox" }}
2022-05-09 23:01:43 +02:00
<div class="w100 checkbox {{- if .group }} visibleIf margin_left_1rem" data-visibleif-rule="{{ .group }}group == 'true'{{ end }}">
2022-04-11 22:38:32 +02:00
<label><input type="checkbox" name="{{ .title }}" id="{{ .title }}" value="{{ .name }}">{{- $name -}}{{- if .help }} ({{ .help }}){{ end }}</label>
2022-04-06 17:51:02 +02:00
</div>
{{ else if eq .input_type "results" }}
2022-05-09 23:01:43 +02:00
<div id='result' class="w100"></div>
2022-04-06 17:51:02 +02:00
{{ else if eq .input_type "submit" }}
2022-04-06 19:06:41 +02:00
<div class="margin_top_1rem {{ if .group }}visibleIf margin_left_1rem" data-visibleif-rule="{{ .group }}group == 'true'{{ end }}">
2022-05-10 04:16:08 +02:00
<input type="{{ .input_type }}" value="{{- $name -}}" onsubmit="return false" onclick="showInput(event);" />
2022-04-06 17:51:02 +02:00
</div>
{{ else if eq .input_type "mc" }}
2022-04-08 17:21:11 +02:00
{{ $in0 := .title }}
2022-04-06 17:51:02 +02:00
{{- $finale := slice -}}
{{ $pages := where site.RegularPages "Type" "in" site.Params.searchSections }}
2022-04-08 17:21:11 +02:00
{{ if eq .title "tags" }}
2022-04-06 17:51:02 +02:00
{{ range $pages }}
2022-04-11 15:45:49 +02:00
{{- with .Params.tags -}}
{{- $finale = $finale | append . -}}
{{ end }}
{{ end }}
{{ else if eq .title "foundations" }}
2022-04-28 18:11:33 +02:00
{{ range resources.Match "/images/foundations/*" }}
2022-04-11 18:16:40 +02:00
{{ $n := path.Base (strings.TrimSuffix (path.Ext .Name) .Name) }}
{{- $finale = $finale | append $n -}}
2022-04-06 17:51:02 +02:00
{{ end }}
{{ else }}
{{ range $pages }}
{{ range .Param $in0 }}
{{- $finale = $finale | append . -}}
{{ end }}
{{ end }}
{{ end }}
{{- $finale = $finale | uniq -}}
2022-05-09 23:01:43 +02:00
<div class="margin_top_1rem column {{ if .group }} visibleIf" data-visibleif-rule="{{ .group }}group == 'true'{{ end }}">
<div class="w100 {{ if .group }}margin_left_1rem{{ end }}">
2022-04-08 17:21:11 +02:00
{{ .name }}
2022-04-10 11:00:14 +02:00
{{ if ne .expanded true }}{{ partial "layout/generator/expand" (dict "name" (printf "%scat" $in0)) }}{{ end }}{{- if .required -}}{{- " *" -}}{{- end -}}
2022-04-06 17:51:02 +02:00
</div>
2022-05-09 23:01:43 +02:00
<div class="checkbox {{ if ne .expanded true }}visibleIf margin_left_1rem stretch" data-visibleif-rule="{{ $in0 }}cat == 'true'{{end}}">
2022-04-11 15:45:49 +02:00
<div class="column margin_left_1rem">
2022-04-12 13:59:02 +02:00
<fieldset id="{{ $in0 }}" name="{{ $in0 }}" class="fieldset">
2022-04-06 17:51:02 +02:00
{{ range sort $finale }}
2022-04-12 13:59:02 +02:00
<label><input type="checkbox" name="{{ $in0 }}" id="{{ $in0 }}{{ . }}" value="{{ . }}" />{{ . }}</label>
2022-04-06 17:51:02 +02:00
{{ end }}
</fieldset>
2022-04-08 17:21:11 +02:00
{{ if .new }}
2022-05-09 23:01:43 +02:00
<label for="new{{- .title -}}">{{ .new }} <span class="font_size_smaller">({{- $divide -}}{{- if .help -}}, {{ .help }}{{ end }})</span></label>
<input class="w100" type="text" name="new{{- .title -}}" id="new{{- .title -}}" value="" {{ if .placeholder }}placeholder="{{ .placeholder }}"{{ end }} />
2022-04-06 17:51:02 +02:00
{{ end }}
</div>
</div>
</div>
{{ else }}
2022-04-08 17:21:11 +02:00
{{ if eq .title "name" }}
2022-04-06 19:06:41 +02:00
<div class="half {{- if .group }} visibleIf margin_left_1rem" data-visibleif-rule="{{ .group }}group == 'true'{{ end }}">
2022-04-08 17:21:11 +02:00
<label class="{{ if $pageform.names }}sr-only{{ end }}" for="firstname">First name{{- if .required -}}{{- " *" -}}{{- end -}}</label>
<input type="text" name="firstname" id="firstname" {{ if $pageform.names }}placeholder="First name{{ .Scratch.Get "requiredstar" }}"{{ end }} {{ .Scratch.Get "requiredtext" }}>
2022-04-06 17:51:02 +02:00
</div>
2022-04-06 19:06:41 +02:00
<div class="half {{- if .group }} visibleIf margin_left_1rem" data-visibleif-rule="{{ .group }}group == 'true'{{ end }}">
2022-04-08 17:21:11 +02:00
<label class="{{ if $pageform.names }}sr-only{{ end }}" for="lastname">Last name{{- if .required -}}{{- " *" -}}{{- end -}}</label>
<input type="text" name="lastname" id="lastname" {{ if $pageform.names }}placeholder="Last name{{ .Scratch.Get "requiredstar" }}"{{ end }} {{ .Scratch.Get "requiredtext" }}>
2022-04-06 17:51:02 +02:00
</div>
2022-04-08 17:21:11 +02:00
{{ else if eq .title "address" }}
2022-04-06 17:51:02 +02:00
<div {{- if .group }} class="visibleIf margin_left_1rem" data-visibleif-rule="{{ .group }}group == 'true'"{{ end -}}>
2022-04-08 17:21:11 +02:00
<label class="{{ if $pageform.names }}sr-only{{ end }}" for="address">Address{{- if .required -}}{{- " *" -}}{{- end -}}</label>
<input type="text" name="address" id="address" {{ if $pageform.names }}placeholder="Address{{ .Scratch.Get "requiredstar" }}"{{ end }} {{ .Scratch.Get "requiredtext" }}>
2022-04-06 17:51:02 +02:00
</div>
2022-04-06 19:06:41 +02:00
<div class="half {{- if .group }} visibleIf margin_left_1rem" data-visibleif-rule="{{ .group }}group == 'true{{ end }}">
2022-04-08 17:21:11 +02:00
<label class="{{ if $pageform.names }}sr-only{{ end }}" for="city">City{{- if .required -}}{{- " *" -}}{{- end -}}</label>
<input type="text" name="city" id="city" {{ if $pageform.names }}placeholder="City{{ .Scratch.Get "requiredstar" }}"{{ end }} {{ .Scratch.Get "requiredtext" }}>
2022-04-06 17:51:02 +02:00
</div>
2022-04-06 19:06:41 +02:00
<div class="half {{- if .group }} visibleIf margin_left_1rem" data-visibleif-rule="{{ .group }}group == 'true'{{ end }}">
2022-04-08 17:21:11 +02:00
<label class="{{ if $pageform.names }}sr-only{{ end }}" for="postalcode">Postal code{{- if .required -}}{{- " *" -}}{{- end -}}</label>
<input type="text" name="postalcode" id="postalcode" {{ if $pageform.names }}placeholder="Postal code{{ .Scratch.Get "requiredstar" }}"{{ end }} {{ .Scratch.Get "requiredtext" }}>
2022-04-06 17:51:02 +02:00
</div>
{{ else }}
2022-05-09 23:01:43 +02:00
<div class="margin_top_1rem w100 {{ if .group }} visibleIf stretch margin_left_1rem" data-visibleif-rule=" {{ .group }}group == 'true' {{ end }}">
<div class="column w100">
<label class="w100 {{ if $pageform.names }}sr-only{{ end }}" for="{{ .title }}">{{ .name }}{{- if .required -}}{{- " *" -}}{{- end -}}{{- if .help }} ({{ .help }}){{ end }}</label>
<input class="w100" type="{{ .input_type }}" name="{{ .title }}" id="{{ .title }}" placeholder="{{ .placeholder }}">
2022-04-06 17:51:02 +02:00
</div>
</div>
{{ end }}
{{ end }}
{{ end }}
</form>