qbbr/entity-hidden-type-bundle

Symfony 2 entity hidden form type

Installs: 8 386

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 0

Open Issues: 0

Type:symfony-bundle

2.0.4 2019-02-15 12:40 UTC

This package is auto-updated.

Last update: 2024-04-14 16:04:41 UTC


README

Latest Stable Version Total Downloads License

Installation

Step 1: Download the Bundle

Symfony >= 2.8

$ composer require qbbr/entity-hidden-type-bundle

Symfony < 2.8

$ composer require qbbr/entity-hidden-type-bundle 1.*

Step 2: Enable the Bundle

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new Qbbr\EntityHiddenTypeBundle\EntityHiddenTypeBundle(),
        );

        // ...
    }

    // ...
}

Usage

<?php
// src/AppBundle/Form/Type/MyType.php
namespace AppBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
// for Symfony < 2.8 rm use type
use Qbbr\EntityHiddenTypeBundle\Form\Type\EntityHiddenType;

class MyType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            // for < 2.8 use 'entity_hidden'
            ->add('parent', EntityHiddenType::class, [
                'class' => 'AppBundle\Entity\MyEntity',
            ]);
    }

    // for < 2.8 use getName()
    public function getBlockPrefix()
    {
        return 'my';
    }
}