浏览代码

Add confirm

Visman 1 年之前
父节点
当前提交
ba2f6a0461
共有 1 个文件被更改,包括 10 次插入0 次删除
  1. 10 0
      app/Models/Pages/Edit.php

+ 10 - 0
app/Models/Pages/Edit.php

@@ -361,6 +361,7 @@ class Edit extends Page
                 'token'      => 'token:ChangeAnD',
                 'token'      => 'token:ChangeAnD',
                 'username'   => 'required|string|username_check',
                 'username'   => 'required|string|username_check',
                 'posted'     => 'required|date',
                 'posted'     => 'required|date',
+                'confirm'    => 'checkbox',
                 'change_and' => 'required|string',
                 'change_and' => 'required|string',
             ])->addAliases([
             ])->addAliases([
                 'username' => 'Username',
                 'username' => 'Username',
@@ -371,6 +372,10 @@ class Edit extends Page
             ]);
             ]);
 
 
             if ($v->validation($_POST)) {
             if ($v->validation($_POST)) {
+                if ('1' !== $v->confirm) {
+                    return $this->c->Redirect->url($post->link)->message('No confirm redirect', FORK_MESS_WARN);
+                }
+
                 $ids     = [];
                 $ids     = [];
                 $upPost  = false;
                 $upPost  = false;
 
 
@@ -501,6 +506,11 @@ class Edit extends Page
                             'required'  => true,
                             'required'  => true,
                             'value'     => $data['posted'] ?? null,
                             'value'     => $data['posted'] ?? null,
                         ],
                         ],
+                        'confirm' => [
+                            'type'      => 'checkbox',
+                            'label'     => 'Confirm action',
+                            'checked'   => false,
+                        ],
                     ],
                     ],
                 ],
                 ],
             ],
             ],