abt/form
Composer 安装命令:
composer require abt/form
包简介
ZF2 / Doctrine integrated form generator
README 文档
README
About
This ZF2 module is built with the intention of converting a Doctrine Entity into a \Zend\Form\Form object and then rendering it on the page.
Installation
- Install via composer
- add the following to your composer.json file:
"fousheezy/form": "dev-master" - add the module to your zend project (from ZF2's root) edit
config/application.config.phpand add'FzyForm'to the'modules'array
Services
- FzyForm\Render returns the rendering service of type:
\FzyForm\Service\Render
View Helpers
- fzyForm accepts a \Zend\Form\Form element and an optional second argument to override the form's options. If no arguments are provided, it returns a
\FzyForm\View\Helper\FzyFormobject
AutoForm
Basics
The majority of configuration on how your form should be output is described on the Doctrine Entity itself within the Zend Form's annotations. All the configurations are contained with the Form Annotation's "Options"
For example:
use Doctrine\ORM\Mapping as ORM;
use Zend\Form\Annotation;
/**
* Class User
* @package Application\Entity\Base
* @ORM\Entity
* @ORM\Table(name="user")
* @Annotation\Options({
* "autorender": {
* "ngModel": "user",
* "fieldsets": {
* {
* "name": \FzyForm\Annotation\FieldSet::DEFAULT_NAME,
* "legend": "Basic Info"
* }
* }
* }
* })
*
*/
This module looks for configuration data within the "autorender" key in @Annotation\Options
- ngModel defines the name of the container which will house the form element values in AngularJS.
- fieldsets defines an array of fieldsets this form contains.
A single fieldset consists of at least a "name" value. You can optionally define rows within a fieldset like so
* "autorender": {
* "ngModel": "user",
* "fieldsets": {
* {
* "name": \FzyForm\Annotation\FieldSet::DEFAULT_NAME,
* "legend": "Basic Info"
* "rows": {
* {"name": "nameRow"},
* {"name": "emailRow"}
* }
* }
* }
* }
Which will order the name row first and the email row second within the default fieldset.
Class properties can be annotated to specify which fieldset or row they belong in, mapping them by name.
/**
* @ORM\Column(type="string", length=255, name="name")
*
* @Annotation\Type("Zend\Form\Element\Text")
* @Annotation\Attributes({
* "data-ng-disabled": "saving",
* "required": true
* })
* @Annotation\Options({
* "label":"Name",
* "autorender": {
* "ngModel": "name"
* }})
* @Annotation\ErrorMessage("Please provide a name")
*
* @var string
*/
protected $name;
/**
* @ORM\Column(type="string", length=255)
* @Annotation\Type("Zend\Form\Element\Text")
* @Annotation\Attributes({
* "data-ng-disabled": "saving"
* })
* @Annotation\Options({
* "label":"Email",
* "autorender": {
* "ngModel": "email"
* }})
* @Annotation\AllowEmpty()
* @Annotation\Validator({"name": "EmailAddress"})
* @Annotation\ErrorMessage("Please provide an email")
* @var string
*/
protected $email;
Similarly, in the property definitions, you can add the "autorender" option to the Zend Forms Annotation\Options docblock to specify:
- ngModel the property this form element will be bound to in the Angular Scope (in this case
user.nameanduser.email) - template the view partial to use to render this element.
abt/form 适用场景与选型建议
abt/form 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 93 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 01 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「form」 「zf2」 「module」 「doctrine」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 abt/form 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 abt/form 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 abt/form 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
LosLog provides some log utility
EdpModuleLayouts is very simple Laminas module for making module-specific layouts insanely easy.
Diese Contao 4 Erweiterung stellt Google reCAPTCHA V2 in Form eines neuen Formularfeldes im Formulargenerator bereit. This extension provides Google reCAPTCHA V2 in the form of a new form field in the form generator of Contao Open Source CMS.
Zend Framework module to leverage the symfony dependency injection container
RCM User HTML views/pages
Builds a Bridge between Zend Expressive and Plugin Managers of Zend\MVC
统计信息
- 总下载量: 93
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-01-14