refactor(web/problem/manage/managers): update_uploader_form

This commit is contained in:
Baoshuo Ren 2022-12-23 22:12:42 +08:00
parent 0f4977727a
commit 4e1d7d8f1a
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

View File

@ -32,26 +32,35 @@ $managers_form = newAddDelCmdForm(
$managers_form->runAtServer(); $managers_form->runAtServer();
if (isSuperUser(Auth::user())) { if (isSuperUser(Auth::user())) {
$update_uploader_form = new UOJBs4Form('update_uploader'); $update_uploader_form = new UOJForm('update_uploader');
$update_uploader_form->appendHTML(
HTML::tag(
'div',
['class' => 'col-auto'],
HTML::tag('label', ['class' => 'col-form-label'], '上传者')
)
);
$update_uploader_form->addInput( $update_uploader_form->addInput(
'new_uploader_username', 'new_uploader_username',
'text', [
'用户名', 'div_class' => 'col-auto',
UOJProblem::info('uploader') ?: 'root', 'default_value' => UOJProblem::info('uploader') ?: 'root',
function ($username, &$vdata) { 'validator_php' => function ($username, &$vdata) {
if (!UOJUser::query($username)) { if (!UOJUser::query($username)) {
return '用户不存在'; return '用户不存在';
} }
$vdata['username'] = $username; $vdata['username'] = $username;
return ''; return '';
}, },
null ]
); );
$update_uploader_form->submit_button_config['align'] = 'compressed'; $update_uploader_form->config['form']['class'] = 'mt-2 row g-3 align-items-center';
$update_uploader_form->submit_button_config['text'] = '修改上传者'; $update_uploader_form->config['submit_container']['class'] = 'col-auto';
$update_uploader_form->submit_button_config['class_str'] = 'mt-2 btn btn-warning'; $update_uploader_form->config['submit_button']['class'] = 'btn btn-warning';
$update_uploader_form->config['submit_button']['text'] = '修改上传者';
$update_uploader_form->config['confirm']['smart'] = true;
$update_uploader_form->handle = function (&$vdata) { $update_uploader_form->handle = function (&$vdata) {
DB::update([ DB::update([
"update problems", "update problems",