Skip to content

Commit 18a673b

Browse files
Restore form inputs on organization create error (#34201)
Keeps the entered inputs when the "organization create" request returns an error. Co-authored-by: wxiaoguang <[email protected]>
1 parent 421d0e5 commit 18a673b

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")
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
@@ -18,15 +18,15 @@
1818
<label for="visibility">{{ctx.Locale.Tr "org.settings.visibility"}}</label>
1919
<div class="inline-right">
2020
<div class="ui radio checkbox">
21-
<input class="enable-system-radio" name="visibility" type="radio" value="0" {{if .DefaultOrgVisibilityMode.IsPublic}}checked{{end}}>
21+
<input class="enable-system-radio" name="visibility" type="radio" value="0" {{if .visibility.IsPublic}}checked{{end}}>
2222
<label>{{ctx.Locale.Tr "org.settings.visibility.public"}}</label>
2323
</div>
2424
<div class="ui radio checkbox">
25-
<input class="enable-system-radio" name="visibility" type="radio" value="1" {{if .DefaultOrgVisibilityMode.IsLimited}}checked{{end}}>
25+
<input class="enable-system-radio" name="visibility" type="radio" value="1" {{if .visibility.IsLimited}}checked{{end}}>
2626
<label>{{ctx.Locale.Tr "org.settings.visibility.limited"}}</label>
2727
</div>
2828
<div class="ui radio checkbox">
29-
<input class="enable-system-radio" name="visibility" type="radio" value="2" {{if .DefaultOrgVisibilityMode.IsPrivate}}checked{{end}}>
29+
<input class="enable-system-radio" name="visibility" type="radio" value="2" {{if .visibility.IsPrivate}}checked{{end}}>
3030
<label>{{ctx.Locale.Tr "org.settings.visibility.private"}}</label>
3131
</div>
3232
</div>
@@ -35,7 +35,7 @@
3535
<div class="inline field" id="permission_box">
3636
<label>{{ctx.Locale.Tr "org.settings.permission"}}</label>
3737
<div class="ui checkbox">
38-
<input type="checkbox" name="repo_admin_change_team_access" checked>
38+
<input type="checkbox" name="repo_admin_change_team_access" {{if .repo_admin_change_team_access}}checked{{end}}>
3939
<label>{{ctx.Locale.Tr "org.settings.repoadminchangeteam"}}</label>
4040
</div>
4141
</div>

0 commit comments

Comments
 (0)