locomotivemtl / charcoal-contrib-formio
使用 form.io 添加表单构建器属性输入的 Charcoal 服务提供商。
0.1.2.2
2022-05-11 21:06 UTC
Requires
- php: >=5.6.0 || >=7.0
- ext-json: *
- locomotivemtl/charcoal-admin: ~0.14
- locomotivemtl/charcoal-property: ~0.7
- locomotivemtl/charcoal-translator: ~0.3.6
Requires (Dev)
- php-coveralls/php-coveralls: ^2.0
- phpunit/phpunit: ^5.7 || ^6.5
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2024-09-12 19:52:38 UTC
README
A Charcoal Charcoal 服务提供商,通过 form.io 添加表单构建器属性输入。
目录
安装
首选(且唯一支持)的方法是使用 Composer
$ composer require locomotivemtl/charcoal-contrib-formio
依赖项
必需
- PHP 5.6+: 推荐使用 PHP 7。
配置
将 formio 模块添加到网站的配置文件中的模块列表。
"modules": { "charcoal/formio/formio": {} }
使用方法
本软件包提供了三种属性类型
formio/form
(表单构建器输入)formio/schema
(表单模式)formio/submission
(保存表单提交)
"my_property": { "type": "formio/form", "l10n": false, "label": "My form property" },
"my_property": { "type": "formio/schema", "l10n": false, "label": "My schema property" },
"my_property_submission": { "type": "formio/submission", "l10n": false, "label": "My submission property" }
注意,目前 formio 属性不支持 l10n
。
在保存对象时更新表单,必须在属性上调用 createOrUpdateRelation()
方法。以下示例保存或更新名为 test
的属性的表单构建器模式。此代码应在对象的控制器中找到。
/** * {@inheritdoc} * * @see StorableTrait::preSave() * @return boolean */ protected function preSave() { $this->test = $this->p('test')->createOrUpdateRelation($this->test, null); return parent::preSave(); } /** * {@inheritdoc} * * @see StorableTrait::preUpdate * @param array $properties Optional properties to update. * @return boolean */ protected function preUpdate(array $properties = null) { $clone = clone $this; // Avoid calling `load()` on current object. $this->test = $this->p('test')->createOrUpdateRelation($this->test, $clone->load()->test); return parent::preUpdate($properties); }
开发
要安装开发环境
$ composer install
运行脚本(phplint、phpcs 和 phpunit)
$ composer test
资源
-
表单渲染文档。对于存储的 form.io 结构的前端渲染很有用。 https://github.com/formio/formio.js/wiki/Form-Renderer
-
Form.io SDK 文档。 http://formio.github.io/formio.js/app/sdk
API 文档
- 自动生成的
phpDocumentor
API 文档可在以下位置找到
https://locomotivemtl.github.io/charcoal-contrib-formio/docs/master/ - 自动生成的
apigen
API 文档可在以下位置找到
https://codedoc.pub/locomotivemtl/charcoal-contrib-formio/master/
开发依赖项
- [php-coveralls/php-coveralls][phpcov]
- [phpunit/phpunit][phpunit]
- [squizlabs/php_codesniffer][phpcs]
编码风格
charcoal-contrib-formio 模块遵循 Charcoal 编码风格
- PSR-1
- PSR-2
- PSR-4,因此自动加载由 Composer 提供。
- phpDocumentor 注释。
- phpcs.xml.dist 和 .editorconfig 用于编码标准。
可以使用
composer phpcs
执行编码风格验证/强制执行。还可以使用composer phpcbf
使用自动修复程序。
致谢
许可证
Charcoal 采用 MIT 许可证。有关详细信息,请参阅 LICENSE。