recordfinder - 渲染一个字段,其中包含相关记录的详细信息. 展开该字段会显示一个弹窗列表,用于搜索大量记录. 仅支持单数关系.
user:
label: User
type: recordfinder
list: ~/plugins/rainlab/user/models/user/columns.yaml以下 字段属性 受支持且常用。
| Property | Description |
|---|---|
| label | a name when displaying the form field to the user. |
| default | specifies a default string value, optional. |
| comment | places a descriptive comment below the field. |
| keyFrom | the name of column to use in the relation used for key. Default: id. |
| nameFrom | the column name to use in the relation used for displaying the name. Default: name. |
| descriptionFrom | the column name to use in the relation used for displaying a description. Default: description. |
| title | text to display in the title section of the popup. |
| list | a configuration array or reference to a list column definition file. |
| filter | a reference to a filter scopes definition file, see backend list filters. |
| showSetup | displays a setup button to configure the list columns and records per page. Default: false |
| structure | enables a read-only structured list for selecting records, see the sorting records article. Set to false to disable, otherwise enabled when the model uses a tree interface. |
| defaultSort | sets a default sorting column and direction when user preference is not defined. Supports a string or an array with keys column and direction. The direction can be asc for ascending (default) or desc for descending order. |
| recordsPerPage | records to display per page, use 0 for no pages. Default: 10 |
| conditions | specifies a raw where query statement to apply to the list 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). The first argument will contain the model that the widget will be attaching its value to, i.e. the parent model. |
| searchMode | defines the search strategy to either contain all words, any word or exact phrase. Supported options: all, any, exact. Default: all. |
| searchScope | specifies a model query scope method defined in the related form model to apply to the search query, the first argument will contain the search term. |
| useRelation | flag for using the name of the field as a relation name to interact with directly on the parent model. Default: true. Disable to return just the selected model's ID |
| modelClass | class of the model to use for listing records when useRelation is false |
| popupSize | change the size of the finder popup used, either: giant, huge, large, small, tiny or adaptive. Default: huge |
| inlineOptions | displays the field with buttons alongside the selected record, disable this mode if horizontal space is limited. Default: true. |
你可以使用 recordsPerPage 属性来限制每页的记录数。
user:
label: User
type: recordfinder
recordsPerPage: 10使用 title 属性来更改管理表单的标题。
user:
label: User
type: recordfinder
title: Find A User当选中一条记录时,显示属性可以从模型属性中选择,使用 nameFrom 和 descriptionFrom 属性。
user:
label: User
type: recordfinder
nameFrom: name
descriptionFrom: email如果检测到模型结构,那么列表将显示为结构。这可以通过使用 structure 属性来显式禁用或启用。
user:
label: User
type: recordfinder
structure: false当 recordfinder 字段用作 Tailor 中的内容字段 时,它需要指定 modelClass 属性以定义和定位模型关系。
products:
label: Products
type: recordfinder
modelClass: Acme\Test\Models\Product
list: $/october/test/models/product/columns.yaml当 maxItems 设置为 1 时,该关系被定义为 belongsTo 关系。否则,该关系被定义为 belongsToMany。
products:
label: Products
type: recordfinder
modelClass: Acme\Test\Models\Tag
maxItems: 1此 inverse 属性可以设置为相关模型上的关系名称。这将根据相关模型的 maxItems 设置和关系类型,将关系定义更改为 hasOne, hasMany 或 belongsToMany。
tags:
label: Tags
type: recordfinder
modelClass: Acme\Test\Models\Tag
inverse: tags