fullscreeninteractive/silverstripe-keyvaluefield
最新稳定版本:3.0.0
Composer 安装命令:
composer require fullscreeninteractive/silverstripe-keyvaluefield
包简介
A Silverstripe FormField for extending TextField with several parts (keys)
README 文档
README
A reusable approach to a form field which extends a simple Text field to have several named parts (keys). This module also supports User Defined Forms.
Installation
composer require fullscreeninteractive/silverstripe-keyvaluefield
Usage
use FullscreenInteractive\KeyValueField\KeyValueField; $fields = new FieldList( KeyValueField::create('Quantity', 'Enter quantity of each size') ->setKeys([ 'Small', 'Medium', 'Large' ]) );
When using ORM managed forms and models (i.e saveInto) data will be saved as
a serialized array of the values to each of the keys. You can change this
behaviour if needed in your Form class.
public function doSave($data, $form) { $quantity = $form->dataFieldByName('Quantity'); // returns an array of key => value $values = json_decode($quantity->dataValue(), true); echo $values['Small'] }
Licence
BSD 3-Clause License
统计信息
- 总下载量: 49
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2022-07-26
