PHP code example of fle / crud-bundle

1. Go to this page and download the library: Download fle/crud-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/ */

    

fle / crud-bundle example snippets



$bundles = array(
    // ...
    new JMS\DiExtraBundle\JMSDiExtraBundle($this),
    new JMS\AopBundle\JMSAopBundle(),
    new FLE\Bundle\CrudBundle\FLECrudBundle(),
    // ...
);



use FLE\Bundle\CrudBundle\Annotation as CRUD;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass="AppBundle\Repository\ObjectRepository")
 * @CRUD\FormFilter(class="AppBundle\Filter\ObjectFilterType")
 */
class Object
{
    //...
}



use FLE\Bundle\CrudBundle\Filter\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Doctrine\ORM\QueryBuilder;

class ObjectFilterType extends AbstractType
{
    /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('articleType', ChoiceType::class, [
            'choices' => [
                'withArticle' => function (QueryBuilder $qb, $rootAlias) {
                    return $qb
                        ->andWhere("$rootAlias.article IS NOT NULL");
                },
                'all' => null
            ],
            'mapped' => false
        ]);
    }
}