entries - 链接到其他条目,通过 UUID 或 handle
author:
label: Author
type: entries
source: <uuid|handle>以下属性受支持。
| Property | Description |
|---|---|
| source | the related blueprint UUID or handle name. |
| maxItems | limits the number of entries that can be selected. |
| displayMode | modifies how the field is displayed. Supported values: relation, recordfinder, taglist, controller. Default: relation. |
| conditions | specifies a raw where query statement to apply to the model query. |
| modelScope | applies a model query scope method to the related form model, can be a model method name or a static PHP class method (Class::method). |
| inverse | when defined as an inverse relationship, the name of the related field in the source blueprint. |
要限制可选项目的数量,请使用 maxItems 属性。
author:
type: entries
maxItems: 1要显示记录查找器而不是典型的控件,请使用 displayMode 属性。此模式仅在只有一个项目可选择时可用。
author:
type: entries
displayMode: recordfinder当存在多个项目时,displayMode 支持使用标签列表选择项目。
author:
type: entries
displayMode: taglist您可以使用以下方法,通过 SQL 或 PHP 限制相关查询。在示例中,相关记录有一个名为 is_featured 渲染为复选框的字段。我们可以将相关记录限制为仅包含标记了此复选框的记录。
你可以使用原始 SQL 查询,通过 conditions 属性来限制相关模型。
categories:
label: Categories
type: entries
source: Blog\Category
conditions: is_featured = true你可以限制相关查询使用一个带有 scope 属性的 PHP 方法。
basic_entries:
label: Basic Entry
type: entries
source: Basic\Entry
scope: App\Classes\ScopeHelper::applyScope这将指代 App\Classes\ScopeHelper 类可能形如一个位于 app/classes/ScopeHelper.php 的文件,例如。
namespace App\Classes;
class ScopeHelper
{
public static function applyScope($query)
{
return $query->where('is_featured', true);
}
}在某些情况下,您可能希望反向访问关系,例如查找属于某个特定类别的所有文章。 该 inverse 属性可用于反向链接关系,其中属性值设置为源蓝图中的字段名称。
例如,如果一个 Blog\Post 蓝图已经定义了一个 categories 关系。
categories:
type: entries
source: Blog\CategoryBlog\Category 蓝图可以包含一个 posts 字段,作为源蓝图(上方)中 categories 字段的 inverse。该字段可以通过将 hidden 值设置为 true 从表单中排除,这是可选的。
posts:
type: entries
source: Blog\Post
inverse: categories
hidden: true默认情况下,entries 字段将显示为指向相关记录的超链接。
要显示列表列以显示相关记录的计数,您可以使用以下 列配置。该 relation 属性应设置为字段名称,其中 relationCount 设置为 true 并且为 number 列类型。
categories:
label: Categories
type: entries
# ...
column:
relation: categories
relationCount: true
type: number要在表单中创建、更新和删除项目,请将 displayMode 设置为 控制器 以显示高级管理模式,该模式由 关系控制器行为 提供支持。
author:
type: entries
displayMode: controller如果蓝图的 navigation 设置为 false 那么默认按钮将显示 创建 和 删除。如果定义了导航,那么按钮显示 添加 和 移除。你可以使用 toolbarButtons 属性自定义这些按钮。
author:
type: entries
toolbarButtons: create|add|remove|delete关系控制器中使用的各种消息取自源蓝图 customMessages,属性,并且您也可以使用字段定义上的 customMessages 修改它们。
author:
type: entries
customMessages:
buttonCreate: New Author
titleUpdateForm: Update Author
titleCreateForm: Create Author