locomotivemtl/charcoal-contrib-formio

使用 form.io 添加表单构建器属性输入的 Charcoal 服务提供商。

0.1.2.2 2022-05-11 21:06 UTC

README

License Latest Stable Version Code Quality Coverage Status Build Status

A Charcoal Charcoal 服务提供商,通过 form.io 添加表单构建器属性输入。

目录

安装

首选(且唯一支持)的方法是使用 Composer

$ composer require locomotivemtl/charcoal-contrib-formio

依赖项

必需

配置

将 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

资源

API 文档

开发依赖项

  • [php-coveralls/php-coveralls][phpcov]
  • [phpunit/phpunit][phpunit]
  • [squizlabs/php_codesniffer][phpcs]

编码风格

charcoal-contrib-formio 模块遵循 Charcoal 编码风格

可以使用 composer phpcs 执行编码风格验证/强制执行。还可以使用 composer phpcbf 使用自动修复程序。

致谢

许可证

Charcoal 采用 MIT 许可证。有关详细信息,请参阅 LICENSE