Skip to content

Commit

Permalink
Add validations.required check to dropdown field (go-gitea#24849)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
yp05327 authored May 22, 2023
1 parent 81ce271 commit 5c0745c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions templates/repo/issue/fields/dropdown.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down

0 comments on commit 5c0745c

Please sign in to comment.