您可以通过扩展 Tailor 构建自定义内容字段。
内容字段 是 该 基石 的 该 Tailor 模块 并 定义 如何 一个 字段 应 被 配置 和 显示。 这些 定义 是 经常 发现 在 该 字段 属性 的 一个 蓝图。
fields:
name:
label: Full Name
type: text可在 后端元素部分 中找到可用字段的完整列表。
对于每个字段,您可以指定这些通用属性,如适用。
| Property | Description |
|---|---|
| label | a name when displaying the form field to the user. |
| shortLabel | a shorter label to use in lists and filters. |
| type | defines how this field should be rendered, see form field definitions. Default: text. |
| span | aligns the form field to one side. Options: auto, left, right, row, full, adaptive. Default: full. |
| spanClass | used with the span row option to display the form as a Bootstrap grid, for example, spanClass: col-4. |
| size | specifies a field size for fields that use it, for example, the textarea field. |
| placeholder | if the field supports a placeholder value. |
| comment | places a descriptive comment below the field. |
| commentAbove | places a comment above the field. |
| commentHtml | allow HTML markup inside the comment. Default: false. |
| default | specify the default value for the field. For dropdown, checkboxlist, radio and balloon-selector widgets, you may specify an option key here to have it selected by default. |
| tab | assigns the field to a tab. |
| validation | defines validation rules for the form field, see the validation article for rule definitions. |
| trigger | specify conditions for this field using trigger events. |
| preset | allows the field value to be initially set by the value of another field, converted using the input preset converter. |
| translatable | disables translation for this field when using the multisite in the blueprint definition. |
当涉及到在列表或筛选器中显示字段时,每个字段都有其自己的默认设置。您可以按字段级别覆盖这些设置,这适用于进行微调。对于更复杂的用例,我们建议将列和作用域与字段分开定义(参见下文)。
| Property | Description |
|---|---|
| column | defines how to display the field in a list, see list column definitions. |
| scope | defines how to display the field in a filter, see filter scope definitions. |
一个例子可以是为每个指定不同的标签 使用字段的 column 或 scope 属性。
myfield:
label: Form Label
column:
label: List Label
scope:
label: Filter Label如果 被设置为 false,那么该字段将被禁用并阻止其显示。
myfield:
label: Form Label
column: false
scope: falseThe column type can be set to invisible to make it hidden from the list by default.
myfield:
label: Form Label
column: invisible您可以独立于表单字段,通过在蓝图中使用 columns 和 scopes 属性来定义作用域和列。当使用外部配置时,默认视图将仅被定义的字段替换。
scopes:
myfield:
label: Filter Label
# [...]
columns:
myfield:
label: List Label
# [...]
fields:
myfield:
label: Form Label
# [...]字段定义必须存在,才能使列或作用域定义有效。若要从表单中隐藏该定义,请使用
hidden: true将其从表单中隐藏,然后使用hidden: false以在列或作用域中显示它。
列表列具有可使用的简写值。传递一个字符串将替换标签,传递 true 将包含默认列,传递 false 将移除该列并且传递 invisible 将使该列不可见。
columns:
myfield: List Label # New Label
myfield: true # Shown
myfield: false # Hidden
myfield: invisible # Invisible
myfield: [...] # Config Array过滤范围具有类似于可使用的列表列的简写值。
scopes:
myfield: Filter Label # New Label
myfield: true # Shown
myfield: false # Hidden
myfield: [...] # Config Array您可以使用 validation 字段属性为表单字段指定验证规则,有关规则定义,请参阅 验证文章。
fields:
myfield:
label: Featured Text
validation: "required|min:15"验证规则也可以在蓝图文件中使用 validation 蓝图属性在外部定义。这允许您设置自定义属性名称和验证消息。
validation:
rules:
myfield: "required|min:15"
attributeNames:
myfield: My Field
customMessages:
myfield.min: "My field has to be at least 15 characters long"
fields:
myfield:
label: Form Label
# [...]该 unique 验证规则是自动配置的并且不需要指定表名。
unique_field:
label: Unique Field
validation: unique该 required 验证规则支持 创建 和 更新 修饰符,使其仅在模型被创建或更新时才适用。以下内容仅在模型尚不存在时才需要。
password:
label: Password
validation: "required:create"每个蓝图记录都包含一些核心字段,如模型属性所定义。您可以在特定条件下修改这些字段。
条目默认启用;但是,你可以通过为 is_enabled 字段指定一个新的默认值来修改此设置。
fields:
is_enabled:
default: falsetitle 字段的占位符是根据蓝图名称生成的;但是,你可以根据用例将其自定义为更有用的内容。例如,名和姓、活动标题 或 地点名称。
fields:
title:
placeholder: Event Title在某些情况下,title 字段可能不是必需的,例如使用 单个蓝图,您可以将 hidden 属性设置为 true。 隐藏标题将禁用此字段的内置验证。
fields:
title:
hidden: true