lzakrzewski/symfony-form-generator
Composer 安装命令:
composer require lzakrzewski/symfony-form-generator
包简介
Generic solution to create forms "on the fly" basing on class metadata
README 文档
README
This package adds feature for generating symfony forms "on the fly" basing on class metadata like:
Formannotations,- type hints,
- phpdoc comments,
- validator annotations.
Created forms are able to submit with raw data (boolean, integer, string, array, real, double, float).
Example
Object of given class:
use Lzakrzewski\SymfonyFormGenerator\Annotation\Form; use Symfony\Component\Validator\Constraints as Assert; class ObjectWithMixedMetadata { /** * @var bool */ public $propertyBoolean; /** * @Assert\Count(max="5") */ public $propertyArray; /** * @Form\Field("integer", options={"label"="Property Integer"}) */ public $propertyInteger; public $propertyDateTime; public $propertyUndefined; public function __construct($propertyBoolean, $propertyArray, $propertyInteger, \DateTime $propertyDateTime, $propertyUndefined) { $this->propertyBoolean = $propertyBoolean; $this->propertyArray = $propertyArray; $this->propertyInteger = $propertyInteger; $this->propertyDateTime = $propertyDateTime; $this->propertyUndefined = $propertyUndefined; } }
after:
$form = GeneratorFactory::createGenerator() ->generateFormBuilder(ObjectWithMixedMetadata::class) ->getForm();
will have form equivalent:
use Lzakrzewski\SymfonyFormGenerator\Form\Type\GeneratorFormType; use Lzakrzewski\SymfonyFormGenerator\ObjectWithMixedMetadata; use Symfony\Component\Form\Forms; Forms::createFormFactory()->createBuilder() ->create('form', new GeneratorFormType(ObjectWithMixedMetadata::class)) ->add('propertyBoolean', 'checkbox') ->add('propertyArray', 'generator_array') ->add('propertyInteger', 'integer') ->add('propertyDateTime', 'generator_datetime') ->add('propertyUndefined', 'generator_string');
generator_array type extends collection,
generator_datetime type extends datetime,
generator_string type extends text.
generator_* types are custom form types for better support raw values.
Documentation
Topics:
lzakrzewski/symfony-form-generator 适用场景与选型建议
lzakrzewski/symfony-form-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 60 次下载、GitHub Stars 达 1, 最近一次更新时间为 2016 年 02 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 lzakrzewski/symfony-form-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lzakrzewski/symfony-form-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 60
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 10
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-02-07