OctoberCMS:如何防止将提交的表单保存到数据库中?

OctoberCMS: How to prevent a form filed from being saved into database?

我有一个如下所示的表单字段定义文件:

fields:
    pivot[hall]:
        label: Hall
        type: text
        span: auto

    pivot[booth]:
        label: Booth
        type: text
        span: auto

    booth_picker:
        label: Select Booth
        type: boothpicker
        span: full

第三个字段只是一个表单小部件,它提供了一种方便的可视化方式来设置 booth 字段的值。因此,我不需要将 booth_picker 字段提交并保存到数据库中,因为 table 中没有该字段。只有 hallbooth 需要提交和保存。我目前收到此错误:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'booth_picker' in 'field list' (SQL: update users set updated_at = 2016-12-15 13:14:44, booth_picker = where id = 37)"

如何防止提交此帮助字段?或者也许有一种方法可以在模型保存到数据库之前删除此字段?

尝试在您的字段名称前添加下划线(新的 October Cms 功能,因此您可能需要将其升级到版本 382)

那样_booth_picker

编辑:我不确定,但似乎此功能不适用于复选框字段:-(

我们可以在purgeable属性中定义字段名称。

Purged attributes will not be saved to the database when a model is created or updated. To purge attributes in your model, apply the October\Rain\Database\Traits\Purgeable trait and declare a $purgeable property with an array containing the attributes to purge.

    /**
     * @var array List of attributes to purge.
     */

    protected $purgeable = ['booth_picker'];

Reference