From a26a6c961fc785bf76f15f14ddfe35369c704dab Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Tue, 27 Dec 2022 11:44:47 +0800 Subject: [PATCH] refactor(web/groups): uoj_form_v2 --- web/app/controllers/groups.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/web/app/controllers/groups.php b/web/app/controllers/groups.php index 200fc7d..98dd465 100644 --- a/web/app/controllers/groups.php +++ b/web/app/controllers/groups.php @@ -7,14 +7,18 @@ requirePHPLib('data'); Auth::check() || redirectToLogin(); if (UOJGroup::userCanCreateGroup(Auth::user())) { - $new_group_form = new UOJBs4Form('new_group'); + $new_group_form = new UOJForm('new_group'); $new_group_form->handle = function () { - DB::query("insert into `groups` (title, is_hidden) values ('新小组', 1)"); + DB::insert([ + "insert into `groups`", + DB::bracketed_fields(['title', 'is_hidden']), + "values", DB::tuple(['新小组', 1]), + ]); }; - $new_group_form->submit_button_config['align'] = 'right'; - $new_group_form->submit_button_config['class_str'] = 'btn btn-primary'; - $new_group_form->submit_button_config['text'] = UOJLocale::get('add new group'); - $new_group_form->submit_button_config['smart_confirm'] = ''; + $new_group_form->config['submit_container']['class'] = 'text-end'; + $new_group_form->config['submit_button']['class'] = 'btn btn-primary'; + $new_group_form->config['submit_button']['text'] = UOJLocale::get('add new group'); + $new_group_form->config['confirm']['smart'] = true; $new_group_form->runAtServer(); } ?> @@ -23,7 +27,7 @@ if (UOJGroup::userCanCreateGroup(Auth::user())) {
-
+

@@ -31,11 +35,8 @@ if (UOJGroup::userCanCreateGroup(Auth::user())) {

-
- printHTML(); ?> -
+ printHTML() ?> -
@@ -91,11 +92,11 @@ if (UOJGroup::userCanCreateGroup(Auth::user())) { ] ); ?> -
+ -