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: 1inverse 属性可以设置为关联模型上的关联名称。这将根据关联模型的 maxItems 设置和关联类型,将关联定义更改为 hasOne、hasMany 或 belongsToMany。
tags:
label: Tags
type: recordfinder
modelClass: Acme\Test\Models\Tag
inverse: tags