silvester/reverse-form
Composer 安装命令:
composer require silvester/reverse-form
包简介
Rendering ZF2 forms with viewscripts. It can be extended to render with other frameworks then Twitter Bootstrap.
README 文档
README
This is an early alpha, things do work but may be changed how they work in future.
Uni-Form form demo at: http://reverseform.modo.si/form/test-uniform
Twitter Bootstrap form demo at: http://reverseform.modo.si/form/test-bootstrap
Introduction
ReverseForm is a form rendering module. It creates the renderer objects through a view helper. It also provides an object which extends Zend\Form\Element called ReverseForm\ExtendedElement which will be usefull to create more complicated elements faster.
Goals
- Support other frameworks for rendering forms like mobile ones.
- Add an unified way of creating new elements. It should take care of the JS, CSS and configuration part of an element.
- Elements should honor localization.
Installation with Composer
- Add this project in your
composer.json:
"require": { "silvester/reverse-form": "dev-master", }
- Fetch the repository with composer:
$ php composer.phar update
- Enable it in your
config/application.config.phpfile:
return array( 'modules' => array( // ... 'ReverseForm', ), // ... );
Form Renderers
Currently I provide 2 types of renderers, but it is simple to create other renderers by
extending the ReverseForm\Renderer. Before you start take a look at the /config/module.config.php all of the options are there.
- ReverseForm\Renderer\Uniform renders the form with extra markup to make it work with Uni-Form.
- ReverseForm\Renderer\Bootstrap obviously renders Twitter Bootstrap.
Uniform Renderer
$this->form->setAttribute('action', $this->url('album', array('action' => 'test-form'))); $formRenderer = $this->formRenderer($form, 'renderer.uniform', 'vertical'); // vertical or horizontal $formRenderer->prepare(); // this is how you create it in your viewscript
Get your css from Uni-Form. Check the path to load the files in the module_config.php.
Bootstrap Renderer
$this->form->setAttribute('action', $this->url('album', array('action' => 'test-form'))); $formRenderer = $this->formRenderer($form, 'renderer.bootstrap', 'vertical'); // vertical or horizontal $formRenderer->prepare(); // this is how you create it in your viewscript
It does not auto load any css or js files in to your view. If you need to load extra files you can do it from the configuration.
Usage
In your view script do:
<h1>Form Testing</h1> <?php $form = $this->form; $form->setAttribute('action', $this->url('album', array('action' => 'test-form'))); $formRenderer = $this->formRenderer($form, 'renderer.uniform', 'horizontal'); $formRenderer->prepare(); echo $formRenderer->openTag(); ?> <div class="well"> <?php print_r($form->getMessages()); ?> </div> <fieldset class="<?= $formRenderer->_formStyle; ?>"> <legend>Some Legend</legend> <?= $formRenderer->formHidden($form->get('security')); ?> <?= $formRenderer->formRow($form->get('status')); ?> <?= $formRenderer->formRow($form->get('status2')); ?> <?= $formRenderer->formRow($form->get('status3')); ?> <?= $formRenderer->formRow($form->get('codemirrortest')); ?> <?= $formRenderer->formRow($form->get('tinymcetest')); ?> <?= $formRenderer->formRow($form->get('datepicker')); ?> <?= $formRenderer->formRow($form->get('datetimepicker')); ?> <?= $formRenderer->formRow($form->get('daterangepicker')); ?> <?= $formRenderer->formCaptcha($form->get('captchaImage')); ?> <?= $formRenderer->formRow($form->get('gmap')); ?> <?= $formRenderer->formRow($form->get('artist')); ?> <?= $formRenderer->formRow($form->get('title')); ?> <?= $formRenderer->formRow($form->get('file')); ?> <?= $formRenderer->formRow($form->get('countrytextarea')); ?> <?= $formRenderer->formAction($form->get('actions')); ?> </fieldset> <?= $formRenderer->closeTag(); ?> <script>$(document).ready(function(){<?= $formRenderer->getElementJsContent(); ?>});</script>
In your action do:
$form = new ReverseForm\Form\TestForm(); if ($this->getRequest()->isPost()) { $form->setInputFilter(new InputFilter); $form->setData($this->getRequest()->getPost()); } return array('form' => $form, 'post' => $this->getRequest()->getPost());
You would do it better
Feel free to improve it. Will merge them in to the project and thank you.
TODO
- Many element view scripts look the same, only difference is the js part. Refactor all same looking elements in to one viewscript. COMPLETED.
- Write some decent documentation.
- Demo module is on it's way.
- Figure out fieldset templates current way is too ugly
silvester/reverse-form 适用场景与选型建议
silvester/reverse-form 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 695 次下载、GitHub Stars 达 12, 最近一次更新时间为 2012 年 11 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「form」 「zf2」 「module」 「uniform」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 silvester/reverse-form 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 silvester/reverse-form 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 silvester/reverse-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
统计信息
- 总下载量: 695
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2012-11-14