Skip to content

Commit 64555d6

Browse files
bytedreamwxiaoguang
authored andcommitted
Restore form inputs on organization create error (go-gitea#34201)
Keeps the entered inputs when the "organization create" request returns an error. Co-authored-by: wxiaoguang <[email protected]> (cherry picked from commit 18a673b)
1 parent 603d655 commit 64555d6

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

routers/web/org/org.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,14 @@ const (
2727
// Create render the page for create organization
2828
func Create(ctx *context.Context) {
2929
ctx.Data["Title"] = ctx.Tr("new_org.title")
30-
ctx.Data["DefaultOrgVisibilityMode"] = setting.Service.DefaultOrgVisibilityMode
3130
if !ctx.Doer.CanCreateOrganization() {
3231
ctx.ServerError("Not allowed", errors.New(ctx.Locale.TrString("org.form.create_org_not_allowed")))
3332
return
3433
}
34+
35+
ctx.Data["visibility"] = setting.Service.DefaultOrgVisibilityMode
36+
ctx.Data["repo_admin_change_team_access"] = true
37+
3538
ctx.HTML(http.StatusOK, tplCreateOrg)
3639
}
3740

templates/org/create.tmpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
<span class="inline required field"><label for="visibility">{{ctx.Locale.Tr "org.settings.visibility"}}</label></span>
2020
<div class="inline-grouped-list">
2121
<div class="ui radio checkbox">
22-
<input class="enable-system-radio" name="visibility" type="radio" value="0" {{if .DefaultOrgVisibilityMode.IsPublic}}checked{{end}}>
22+
<input class="enable-system-radio" name="visibility" type="radio" value="0" {{if .visibility.IsPublic}}checked{{end}}>
2323
<label>{{ctx.Locale.Tr "org.settings.visibility.public"}}</label>
2424
</div>
2525
<div class="ui radio checkbox">
26-
<input class="enable-system-radio" name="visibility" type="radio" value="1" {{if .DefaultOrgVisibilityMode.IsLimited}}checked{{end}}>
26+
<input class="enable-system-radio" name="visibility" type="radio" value="1" {{if .visibility.IsLimited}}checked{{end}}>
2727
<label>{{ctx.Locale.Tr "org.settings.visibility.limited"}}</label>
2828
</div>
2929
<div class="ui radio checkbox">
30-
<input class="enable-system-radio" name="visibility" type="radio" value="2" {{if .DefaultOrgVisibilityMode.IsPrivate}}checked{{end}}>
30+
<input class="enable-system-radio" name="visibility" type="radio" value="2" {{if .visibility.IsPrivate}}checked{{end}}>
3131
<label>{{ctx.Locale.Tr "org.settings.visibility.private"}}</label>
3232
</div>
3333
</div>
@@ -37,7 +37,7 @@
3737
<span class="inline field"><label>{{ctx.Locale.Tr "org.settings.permission"}}</label></span>
3838
<div class="inline-grouped-list">
3939
<div class="ui checkbox">
40-
<input type="checkbox" name="repo_admin_change_team_access" checked>
40+
<input type="checkbox" name="repo_admin_change_team_access" {{if .repo_admin_change_team_access}}checked{{end}}>
4141
<label>{{ctx.Locale.Tr "org.settings.repoadminchangeteam"}}</label>
4242
</div>
4343
</div>

0 commit comments

Comments
 (0)