cakephp - cakephp:plumSearch - 在参数中更改过滤器的标签
问题描述
使用 PlumSearch 插件,它的文档中提到我们可以修改“标签”:
formConfig:包含 Form::input $options 设置,如类、输入类型、标签名称...
在我的控制器/初始化()中,我需要更改某些字段的标签(“IP 地址”而不是“IP 地址”,“状态”而不是“资产状态”):
public function initialize()
{
parent::initialize();
$parameters = [
['name' => 'serial_number', 'className' => 'Input'],
['name' => 'model_number', 'className' => 'Input'],
['name' => 'ip_address', 'label' => 'IP Address', 'className' => 'Input'],
];
if ($this->request->param('action') == 'reportFacility') {
$statuses = $this->AssetsAssignations->AssetStatuses->find('list')->order(['name' => 'asc']);
$this->set(compact('asset_statuses'));
$parameters = [
['name' => 'asset_status_id', 'className' => 'Select', 'label' => 'Status',
'finder' => $statuses
],
];
} elseif ($this->request->param('action') == 'reportClient') {
$clients = $this->AssetsAssignations->Clients->find('list')->order(['last_name' => 'asc', 'first_name' => 'asc']);
$this->set(compact('clients'));
$parameters = [
['name' => 'client_id', 'className' => 'Select', 'label' => 'Client',
'finder' => $clients
],
];
} elseif ($this->request->param('action') == 'reportRoom') {
$rooms = $this->AssetsAssignations->Rooms->find('list')->order(['name' => 'asc']);
$this->set(compact('rooms'));
$parameters = [
['name' => 'room_id', 'className' => 'Select', 'label' => 'Room',
'finder' => $rooms
],
];
}
$this->loadComponent('PlumSearch.Filter', ['parameters' => $parameters]);
}`
上面的代码不适用于标签。
有人告诉我使用以下代码:
$inputOptions = [
'search' => [
'placeholder' => __('Type to search...'),
'class' => 'form-control',
'label' => 'Search'
]
];
$this->set(compact('inputOptions'));
但我无法确定我的代码中的位置和方式。
请问有什么帮助吗?
解决方案
只是你必须以这种方式将它添加到$parameters
数组中
$parameters = [
/* other fields here */
[
'name' => 'ip_address',
'className' => 'Input',
'formConfig' => ['label' => 'IP Address']
],
];
推荐阅读
- android - Android 的双簧管库中是否支持音频处理?
- html - 表格的滚动条将文本向左推?
- sql - ORA-00933: SQL 命令未正确结束——我错过了什么?
- javascript - Angular链接重定向而不是下载
- android - 修复 GraphView 标题 X 轴的间距
- java - 如何在不知道完整文件路径的情况下访问文件?
- r - 从 Stacked Caret 模型绘制最终决策树
- javascript - 使用 a-frame 时,我可以在哪里添加“timeupdate”事件?
- python - DRF_YASG 生成的文档中的自由格式文本
- php - 如何使用 Oracle 结果集在 Laravel 中分页(不使用 Eloquent)