2017 © Pedro Peláez
 

library gregwar-form

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

image

evolutto/gregwar-form

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

  • Monday, May 7, 2018
  • by h00dstoker
  • Repository
  • 1 Watchers
  • 0 Stars
  • 19 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 27 Forks
  • 0 Open issues
  • 5 Versions
  • 111 % Grown

The README.md

Gregwar's FormBundle

paypal, (*1)

GregwarFormBundle provides the form type "entity_id", (*2)

Installation

To install GregwarFormBundle, run composer require evolutto/gregwar-form., (*3)

Then, register the bundle in the application kernel :, (*4)

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

Finally, add the following block to the configuration :, (*5)

# 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., (*6)

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

<?php
//...
$builder
    ->add('city', 'entity_id', 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., (*8)

You can also chose to show the field, by passing the hidden option to false:, (*9)

<?php
//...
$builder
    ->add('city', 'entity_id', 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:, (*10)

<?php
//...
$builder
    ->add('recipient', 'entity_id', 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., (*11)

License

This bundle is under MIT license, (*12)

The Versions

25/06 2014

2.5

2.5.0.0

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

  Sources   Download

MIT

The Requires

 

19/12 2013

2.4

2.4.0.0

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

  Sources   Download

MIT

The Requires