定制 gregwar/form-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

gregwar/form-bundle

最新稳定版本:2.7

Composer 安装命令:

composer require gregwar/form-bundle

包简介

Provides the "entity_id" type (read "entity identifier")

README 文档

README

paypal

GregwarFormBundle provides the form type "entity_id"

Installation

To install GregwarFormBundle, run composer require gregwar/form-bundle.

Then, register the bundle in the application kernel :

<?php
// app/AppKernel.php
//...
public function registerBundles()
{
    $bundles = array(
        ...
        new Gregwar\FormBundle\GregwarFormBundle(),
        ...
    );
...

Finally, add the following block to the configuration :

# app/config/config.yml
gregwar_form: ~

Usage

The entity_id is a field that contains an entity id, this assumes you set up javascripts or any UI logics to fill it programmatically.

The usage look like the entity field type one, except that the query builder have to returns one unique result. One full example :

<?php
//...
$builder
    ->add('city', EntityIdType::class, array(
        'class' => 'Project\Entity\City',
        'query_builder' => function(EntityRepository $repo, $id) {
            return $repo->createQueryBuilder('c')
                ->where('c.id = :id AND c.available = 1')
                ->setParameter('id', $id);
        }
    ))
    ;

Note that if you don't provide any query builder, ->find($id) will be used.

You can also chose to show the field, by passing the hidden option to false:

<?php
//...
$builder
    ->add('city', EntityIdType::class, array(
        'class' => 'Project\Entity\City',
        'hidden' => false,
        'label' => 'Enter the City id'
    ))
    ;

Using the property option, you can also use another identifier than the primary key:

<?php
//...
$builder
    ->add('recipient', EntityIdType::class, array(
        'class' => 'Project\Entity\User',
        'hidden' => false,
        'property' => 'login',
        'label' => 'Recipient login'
    ))
    ;

Notes

There is maybe bugs in this implementations, this package is just an idea of a form field type which can be very useful for the Symfony2 project.

License

This bundle is under MIT license

统计信息

  • 总下载量: 416.21k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 64
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 64
  • Watchers: 4
  • Forks: 26
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-09-24