1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-22 12:54:53 -05:00

Add validations.required check to dropdown field (#24849)

If dropdown is marked as required, we should not provide the `remove`
button.
This will cause user may post empty value which seems like a bug.

Definition:

![image](https://github.com/go-gitea/gitea/assets/18380374/cf48b478-244e-44e0-9a0e-7a0f02bc471a)
Post request form:

![image](https://github.com/go-gitea/gitea/assets/18380374/31d6f823-835f-422a-879c-3b1e18950ac8)
Result:

![image](https://github.com/go-gitea/gitea/assets/18380374/a9944fe9-24d0-4776-9eec-d31b70144eb4)
This commit is contained in:
yp05327 2023-05-23 06:26:48 +09:00 committed by GitHub
parent 81ce271f78
commit 5c0745c034
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,7 +4,9 @@
<div class="ui fluid selection dropdown {{if .item.Attributes.multiple}}multiple clearable{{end}}">
<input type="hidden" name="form-field-{{.item.ID}}" value="0">
{{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}}