Fieldset Type in Symfony Forms
Switch branches/tags
Clone or download
adamquaile Removed version constraint from composer.json
This is in favour of git tags, so it's correctly picked up by packagist.

#11 (comment)
Latest commit 209f257 May 24, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
DependencyInjection Removing unnecessary phpdoc block Nov 7, 2014
Form Small cleanup + fixing more deprecated calls. Dec 22, 2015
Resources Add fieldset legend translation Mar 13, 2016
.gitignore Initial commit May 17, 2014
.travis.yml
AdamQuaileFieldsetBundle.php Initial commit May 17, 2014
README.md PHP codeblocks in README.md Nov 29, 2015
composer.json

README.md

Symfony Forms Fieldset Type

Adds a fieldset type to a symfony project.

Installation

Install via composer from adamquaile/symfony-fieldset-bundle.

Register in app/AppKernel.php:

public function registerBundles()
{
    $bundles = array(
        // ...
        new AdamQuaile\Bundle\FieldsetBundle\AdamQuaileFieldsetBundle(),
    );

    //...
}

Usage

Use with normal form builder methods:

// A fieldset with your fields defined in a callback function
$builder->add('my_group_example_one', 'fieldset', [
    'label' => false, // You probably don't want a label as well as a legend.
    'legend' => 'Your fieldset legend',
    'fields' => function(FormBuilderInterface $builder) {
        $builder->add('first_name', 'text', [
            'label' => 'First Name'
        ]);
        $builder->add('last_name', 'text', [
            'required'  => false,
            'label'     => 'Surname'
        ]);
    }
]);

// A fieldset with your fields defined in an array
$builder->add('my_group_example_two', 'fieldset', [
    'label' => false,
    'legend' => 'Your fieldset legend',
    'fields' => [
        [
            'name'  => 'first_name',
            'type'  => 'text',
            'attr'  => [
                'label' => 'First Name'
            ]
        ],
        [
            'name'  => 'last_name',
            'type'  => 'text',
            'attr'  => [
                'required'  => false,
                'label'     => 'Surname'
            ]
        ]
    ]
]);