2017 © Pedro Peláez
 

library document-id-form-bundle

Provides the "document_id" form type

image

omouren/document-id-form-bundle

Provides the "document_id" form type

  • Sunday, June 26, 2016
  • by omouren
  • Repository
  • 1 Watchers
  • 0 Stars
  • 13 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

DocumentIdFormBundle

Provides the form type "document_id" using Doctrine ODM. Based on the work of Gregwar : FormBundle, (*1)

Installation

composer require omouren/document-id-form-bundle., (*2)

Register the bundle in the application kernel :, (*3)

<?php
// app/AppKernel.php
//...
public function registerBundles()
{
    $bundles = array(
        ...
        new Omouren\DocumentIdFormBundle\OmourenDocumentIdFormBundle(),
        ...
    );
...

Add the following after the twig block to the configuration :, (*4)

# app/config/config.yml
# Twig Configuration
twig:
    ...
    form_themes:
        - 'OmourenDocumentIdFormBundle::document_id_type.html.twig'

Usage

The document_id is a field that contains an document id, this assumes you set up javascripts or any UI logics to fill it programmatically., (*5)

The usage look like the document field type one, except that the query returns one unique result. One example :, (*6)

<?php
//...
$builder
    ->add('city', 'document_id', [
        'class' => 'Project\Entity\City',
    ])
    ;

Here ->find($value) will be used., (*7)

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

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

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

The Versions