Octobercms后端Builder表单-自动验证?

问题描述 投票:0回答:1

一个星期以来我一直在尝试验证后端Builder表单...

未在YAML中使用Builder验证规则,我在代码$ rules和$ customMessages中放入了代码,但是在提交数据库时会触发它们的注释。

我的空表格已成功创建或更新!!!我以为Octobercms正在做烦人的验证工作。

我想念的是什么?感谢您的帮助,我快疯了!

我的Yaml没有验证规则:

 fields:
    client_name:
        label: 'Name'
        span: auto
        type: text

我的模型是:

use Model;
use Validator;

/**
 * Model
 */
class Commande extends Model
{
    use \October\Rain\Database\Traits\Validation;
    use \October\Rain\Database\Traits\SoftDelete;
    use \October\Rain\Database\Traits\Nullable;

    protected $nullable = ['comment'];    // Pour utilisation de Nullable trait

    /*
     * Disable timestamps by default.
     * Remove this line if timestamps are defined in the database table.
     */
    public $timestamps = false;


    /**
     * @var string The database table used by the model.
     */
    public $table = 'lb_book_commandes';

    /**
     * @var array Validation rules
     */
    public $rules = [
        'client_name' => 'required'
    ];

    // Messages d'erreur de validation
    public $customMessages = [
        'client_name.required' => 'Name not typed',
    ];

    // Affichage de plusieurs messages de validation en une fois.
    public $throwOnValidation = false;

}
octobercms octobercms-backend october-form-controller
1个回答
0
投票

最后,我通过这篇文章解决了我的问题:OctoberCMS plugin show all the validations at once

某些代码干扰了验证...

© www.soinside.com 2019 - 2024. All rights reserved.