OctoberCms笔记-Backend-Forms

Backend-Forms

Record finder

-呈现包含相关记录详细信息的字段。展开字段会显示一个弹出列表以搜索大量记录。仅受单一关系支持。

可以以某一列表记录的字段作为表单的值

文档案例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
user:
label: User
type: recordfinder
list: ~/plugins/rainlab/user/models/user/columns.yaml
recordsPerPage: 10
title: Find Record
prompt: Click the Find button to find a user
keyFrom: id
nameFrom: name
descriptionFrom: email
conditions: email = "bob@example.com"
scope: whereActive
searchMode: all
searchScope: searchUsers
useRelation: false
modelClass: RainLab\User\Models\User

我的案例

1
2
3
4
5
6
7
8
9
text_id:
label: 文本素材
nameFrom: content
descriptionFrom: description
list: $/plus/weiphp/models/materialtext/columns.yaml
span: full
type: recordfinder
useRelation: false
modelClass: Plus\Weiphp\Models\MaterialText

注意事项

1
2
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 = false

我的理解

我理解的意思是,当两个表关联的字段一样且都存在的时候 useRelation 可以用默认的 true;当不一样的时候,比如我的自定义回复表中的 text_id
对应文本素材表的 id 则需要将 useRelation设置为 false,同时要将 modelClass 指向对应的模型

效果展示

a01

Field options trigger

- specify conditions for this field using trigger events.

- 使用触发器事件指定此字段的条件。

其他字段触发本字段做动作

文档案例

1
2
3
4
5
6
7
8
9
10
11
12
13
is_delayed:
label: Send later
comment: Place a tick in this box if you want to send this message at a later time.
type: checkbox

send_at:
label: Send date
type: datepicker
cssClass: field-indent
trigger:
action: show
field: is_delayed
condition: checked

我的案例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
msg_type:
label: 选择类型
options:
text: 文本
img: 图片
news: 图文
voice: 语音
video: 视频
span: full
type: radio
text_id:
label: 文本素材
nameFrom: content
descriptionFrom: description
list: $/plus/weiphp/models/materialtext/columns.yaml
span: full
type: recordfinder
useRelation: false
modelClass: Plus\Weiphp\Models\MaterialText
trigger:
action: show
field: msg_type
condition: value[text]
img_id:
label: 图片素材
nameFrom: content
descriptionFrom: description
list: $/plus/weiphp/models/materialimage/columns.yaml
span: full
type: recordfinder
useRelation: false
modelClass: Plus\Weiphp\Models\MaterialImage
trigger:
action: show
field: msg_type
condition: value[img]

注意事项 Trigger events

1
2
3
4
Option	Description
action defines the action applied to this field when the condition is met. Supported values: show, hide, enable, disable, empty.
field defines the other field name that will trigger the action. Normally the field name refers to a field in the same level form. For example, if this field is in a repeater widget, only fields in that same repeater widget will be checked. However, if the field name is preceded by a caret symbol ^ like: ^parent_field, it will refer to a repeater widget or form one level higher than the field itself. Additionally, if more than one caret ^ is used, it will refer that many levels higher: ^^grand_parent_field, ^^^grand_grand_parent_field, etc.
condition determines the condition the specified field should satisfy for the condition to be considered "true". Supported values: checked, unchecked, value[somevalue].

我的理解

当 field 这个字段 达到某种条件或值 也就是 condition 时 ,对应的这个字段将做 action 这样的动作; 如果 action 设成 show 的话,默认是不显示的。

效果展示

a02