PHP code example of gregwar / form-bundle

1. Go to this page and download the library: Download gregwar/form-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gregwar / form-bundle example snippets



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


//...
$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);
        }
    ))
    ;


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


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