ucs/form

UCS Array Form Component

0.9 2015-06-29 18:53 UTC

This package is not auto-updated.

Last update: 2019-09-15 15:55:46 UTC


README

Additional form types for Symfony2:

ArrayFormType

This allows you to build forms from an array definition, this can be very usefull for custom forms loaded from json.

define your fields like the following:

<?php

$options = array(
    'name' => array(
        'type' => 'group', // Can be 'item',
        // If its a group
        'items' => array(), // With same construction as this sample
        // Else
        'value' => 'blabhblahblah',
        'widget' => array(
            'type' => 'text',
            'options' => array(
                'label' => 'Name',
                'help_block' => 'patati patata',
                'trans_domain' => 'MyDomain',
                'required' => true,
                'max_length' => 255,
                'constraints' => array(
                    'length' => array(
                        'min' => 5,
                        'max' => 255
                    )
                )
            )
        )
    )
);

Constraints will be translated into proper symfony2 validation constraints and registered properly in the UCS internal ConstraintMapping.