armetiz/form-extension-bundle
Composer 安装命令:
composer require armetiz/form-extension-bundle
包简介
Symfony Bundle to extend Form
README 文档
README
This bundle add a new Form type named "entity_ajax".
It looks like the default "entity" type, but it loads only associated entities.
Example
A Book is link to User throught "owner" property.
If you are using the "entity" type on the BookType to display the "owner" property. The form will load all the "users" to render the page.
With the "entity_ajax" type, the form will load only the current "owner". In this case, you are free to load further "users" via AJAX or something else.
Installation
Installation is a quick 2 step process:
- Download ArmetizFormExtensionBundle using composer
- Enable the Bundle
Step 1: Download ArmetizFormExtensionBundle using composer
Add ArmetizFormExtensionBundle in your composer.json:
{ "require": { "armetiz/form-extension-bundle": "1.x-dev" } }
Now tell composer to download the bundle by running the command:
$ php composer.phar update armetiz/form-extension-bundle
Composer will install the bundle to your project's vendor/armetiz directory.
Step 2: Enable the bundle
Enable the bundle in the kernel:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Armetiz\FormExtensionBundle\ArmetizFormExtensionBundle(), ); }
Usage
You just have to use "entity_ajax" type instead of "entity". All EntityType options are still availabled and/or needed.
I'm using it with Chosen & Ajax Chosen.
// src/Acme/TaskBundle/Controller/DefaultController.php namespace Acme\TaskBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Acme\TaskBundle\Entity\Task; class DefaultController extends Controller { public function newAction(Request $request) { $task = new Task(); $form = $this->createFormBuilder($task) ->add('task', 'text') ->add('dueDate', 'date') ->add('owner', 'entity_ajax') ->getForm(); if ($request->isMethod('POST')) { $form->bind($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($task); $em->flush(); return $this->redirect($this->generateUrl('task_success')); } } return $this->render('AcmeTaskBundle:Default:new.html.twig', array( 'form' => $form->createView(), )); } }
// part of edit.html.twig file var ajaxChosenSimplifier = function(selector, url, label) { var options = { method: 'GET', url: url, data: { method: "search" }, jsonTermKey: "value", dataType: 'xml' }; var success = function(data, textStatus, jqXHR) { var jSearched = $(data); var result = {}; jQuery.each(jSearched.find("item"), function(indexInArray, item) { var jItem = $(item); var id = jItem.find("id").text(); var text = jItem.find(label).text(); result[id] = text; }); return result; }; return $(selector).ajaxChosen(options, success); }; ajaxChosenSimplifier("#task_owner", "http://api.domain.tld/user, "username");
<!-- data content example --> <response status="success" message="user.search"> <item key="0" id="3" type="user"> <id>3</id> <username><![CDATA[ john ]]></username> </item> <item key="0" id="4" type="user"> <id>4</id> <username><![CDATA[ iron man ]]></username> </item> </response>
armetiz/form-extension-bundle 适用场景与选型建议
armetiz/form-extension-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 231 次下载、GitHub Stars 达 2, 最近一次更新时间为 2012 年 11 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「form」 「bundle」 「ajax」 「entity」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 armetiz/form-extension-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 armetiz/form-extension-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 armetiz/form-extension-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
2lenet/EasyAdminPlusBundle
The bundle for easy using json-rpc api on your project
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.
Provide a way to secure accesses to all routes of an symfony application.
DMS Meetup API Bundle, enables Meetup API clients in services
A Laravel Filament Forms slug field.
统计信息
- 总下载量: 231
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD
- 更新时间: 2012-11-16