Fix boolean inputs in workflow_dispatch; closes #5425

(cherry picked from commit 96c4ca249a)
This commit is contained in:
Mai-Lapyst 2024-10-01 09:22:43 +02:00 committed by forgejo-backport-action
parent a4e5b1b6bc
commit 01e9ac0561
2 changed files with 6 additions and 4 deletions

View file

@ -1,5 +1,5 @@
// Copyright The Forgejo Authors. // Copyright 2024 The Forgejo Authors.
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: GPL-3.0-or-later
package actions package actions
@ -43,7 +43,7 @@ func ManualRunWorkflow(ctx *context_module.Context) {
formKeyGetter := func(key string) string { formKeyGetter := func(key string) string {
formKey := "inputs[" + key + "]" formKey := "inputs[" + key + "]"
return ctx.FormString(formKey) return ctx.Req.PostFormValue(formKey)
} }
if err := workflow.Dispatch(ctx, formKeyGetter, ctx.Repo.Repository, ctx.Doer); err != nil { if err := workflow.Dispatch(ctx, formKeyGetter, ctx.Repo.Repository, ctx.Doer); err != nil {

View file

@ -33,7 +33,9 @@
{{if eq $val.Type "boolean"}} {{if eq $val.Type "boolean"}}
<div class="ui checkbox"> <div class="ui checkbox">
<label><strong>{{if $val.Description}}{{$val.Description}}{{else}}{{$key}}{{end}}</strong></label> <label><strong>{{if $val.Description}}{{$val.Description}}{{else}}{{$key}}{{end}}</strong></label>
<input {{if $val.Required}}required{{end}} type="checkbox" name="inputs[{{$key}}]" {{if eq $val.Default "true"}}checked{{end}}> {{/* These two inputs need to stay in exactly this order (checkbox first, hidden second) or boolean fields wont work correctly! */}}
<input type="checkbox" name="inputs[{{$key}}]" value="on" {{if eq $val.Default "true"}}checked{{end}}>
<input type="hidden" name="inputs[{{$key}}]" value="off" autocomplete="off">
</div> </div>
{{else}} {{else}}
<label>{{if $val.Description}}{{$val.Description}}{{else}}{{$key}}{{end}}</label> <label>{{if $val.Description}}{{$val.Description}}{{else}}{{$key}}{{end}}</label>