浏览代码

Update post form

Visman 2 年之前
父节点
当前提交
63c5797d04
共有 2 个文件被更改,包括 21 次插入6 次删除
  1. 12 6
      app/Models/Pages/PostFormTrait.php
  2. 9 0
      app/Models/Pages/PostValidatorTrait.php

+ 12 - 6
app/Models/Pages/PostFormTrait.php

@@ -99,12 +99,18 @@ trait PostFormTrait
             $this->user->isGuest
             $this->user->isGuest
             || empty($this->user->last_post)
             || empty($this->user->last_post)
         ) {
         ) {
-            $fieldset['terms'] = [
-                'class'   => ['w0'],
-                'type'    => 'checkbox',
-                'label'   => 'I agree to the Terms of Use',
-                'checked' => false,
-            ];
+            if (1 === $this->c->config->b_ant_hidden_ch) {
+                $fieldset['terms'] = [
+                    'class'   => ['w0'],
+                    'type'    => 'checkbox',
+                    'label'   => 'I agree to the Terms of Use',
+                    'checked' => false,
+                ];
+            }
+
+            if (1 === $this->c->config->b_ant_use_js) {
+                $form['hidden']['nekot'] = '';
+            }
         }
         }
 
 
         $form['sets']['uesm'] = [
         $form['sets']['uesm'] = [

+ 9 - 0
app/Models/Pages/PostValidatorTrait.php

@@ -238,6 +238,15 @@ trait PostValidatorTrait
             ]);
             ]);
         }
         }
 
 
+        if (
+            $this->user->isGuest
+            || empty($this->user->last_post)
+        ) {
+            if (1 === $this->c->config->b_ant_use_js) {
+                $v->addRules(['nekot' => 'exist|string|nekot']);
+            }
+        }
+
         return $v;
         return $v;
     }
     }