Skip to content
Hidden entity type for Symfony forms.
PHP Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Shapecode - Hidden Entity Type Bundle

Hidden entity type for Symfony forms.


PHP Version Latest Stable Version Latest Unstable Version Total Downloads Monthly Downloads Daily Downloads License

What is it?

This is a Symfony form type that allows you to add an entity in your form that would be displayed as a hidden input.


Step 1: Download HiddenEntityTypeBundle using composer

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

Composer will install the bundle to your project's vendor directory.

Step 2: Enable the bundle

Enable the bundle in the kernel:

// app/AppKernel.php

public function registerBundles()
    $bundles = array(
        // ...
        new Shapecode\Bundle\HiddenEntityTypeBundle\ShapecodeHiddenEntityTypeBundle(),
        // ...


Simple usage:

You can use the type in your forms just like this:


use Shapecode\Bundle\HiddenEntityTypeBundle\Form\Type\HiddenEntityType;

// ...
$builder->add('entity', HiddenEntityType::class, array(
    'class' => YourBundleEntity::class

You can also use the HiddenDocumentType::class type:


use Shapecode\Bundle\HiddenEntityTypeBundle\Form\Type\HiddenDocumentType;

// ...
$builder->add('document', HiddenDocumentType::class, array(
    'class' => YourBundleDocument::class

There is only one required option "class". You must specify entity class in Symfony format that you want to be used in your form.

Advanced usage:

You can use the HiddenEntityType or HiddenDocumentType type in your forms this way:

// ...
$builder->add('entity', HiddenEntityType::class, array(
    'class' => YourBundleEntity::class, // required
    'property' => 'entity_id', // Mapped property name (default is 'id'), not required
    'multiple' => false, // support for an array of entities, not required
    'data' => $entity, // Field value by default, not required
    'invalid_message' => 'The entity does not exist.', // Message that would be shown if no entity found, not required


From 2.0

The options 'em' and 'dm' are not necessary anymore. The manager will now be load automatically.

Reporting an issue or a feature request

Feel free to report any issues. If you have an idea to make it better go ahead and modify and submit pull requests.


The orginal source is from Glifery ( but seems not to be supported anymore.

You can’t perform that action at this time.