From 398eccb322f64dded83a119467af2cb38f6dbd46 Mon Sep 17 00:00:00 2001
From: JakobDev <jakobdev@gmx.de>
Date: Thu, 19 Oct 2023 13:43:15 +0200
Subject: [PATCH] Fix required checkboxes in issue forms (#27592)

If you set a checkbox as required in a issue form at the moment, the
checkbox is checked and read only, what does not make much sense. With
this PR, the Checkbox actually needs to be checked. The label supports
now also Markdown. This matches GitHub's behaviour.

And yes, I know the CSS is a ugly workaround. It looks like the given
CSS code is part Fomantic and I don't know how to change that. The
Maintainers are free to change that.


![grafik](https://github.com/go-gitea/gitea/assets/15185051/3f35be75-b0b4-42a7-9048-a4970384a035)
---
 templates/repo/issue/fields/checkboxes.tmpl | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/templates/repo/issue/fields/checkboxes.tmpl b/templates/repo/issue/fields/checkboxes.tmpl
index 035ad8e539..237f2eb5dd 100644
--- a/templates/repo/issue/fields/checkboxes.tmpl
+++ b/templates/repo/issue/fields/checkboxes.tmpl
@@ -1,11 +1,14 @@
 <div class="field">
 	{{template "repo/issue/fields/header" .}}
 	{{range $i, $opt := .item.Attributes.options}}
-		<div class="field">
-			<div class="ui checkbox">
-				<input type="checkbox" name="form-field-{{$.item.ID}}-{{$i}}" {{if $opt.required}}readonly checked{{end}}>
-				<label>{{$opt.label}}</label>
+		<div class="field inline">
+			<div class="ui checkbox gt-mr-0">
+				<input type="checkbox" name="form-field-{{$.item.ID}}-{{$i}}" {{if $opt.required}}required{{end}}>
+				<label>{{RenderMarkdownToHtml $.context $opt.label}}</label>
 			</div>
+			{{if $opt.required}}
+				<label class="required"></label>
+			{{end}}
 		</div>
 	{{end}}
 </div>