forgejo/templates/repo/issue/fields/dropdown.tmpl
Zettat123 df15abd072
Support setting the default attribute of the issue template dropdown field (#31045)
Fix #31044

According to [GitHub issue template
documentation](https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema#attributes-for-dropdown),
the `default` attribute can be used to specify the preselected option
for a dropdown field.

(cherry picked from commit 7ab0988af140aa3e0204979765f75961f1dc9c11)
2024-05-26 20:13:09 +02:00

17 lines
681 B
Go HTML Template

<div class="field {{if not .item.VisibleOnForm}}tw-hidden{{end}}">
{{template "repo/issue/fields/header" .}}
{{/* FIXME: required validation */}}
<div class="ui fluid selection dropdown {{if .item.Attributes.multiple}}multiple clearable{{end}}">
<input type="hidden" name="form-field-{{.item.ID}}" value="{{.item.Attributes.default}}">
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
{{if not .item.Validations.required}}
{{svg "octicon-x" 14 "remove icon"}}
{{end}}
<div class="default text"></div>
<div class="menu">
{{range $i, $opt := .item.Attributes.options}}
<div class="item" data-value="{{$i}}">{{$opt}}</div>
{{end}}
</div>
</div>
</div>