This bundle integrates library SymfonyFormGenerator with symfony framework., (*1)
Example
Object of given class:, (*2)
use Lzakrzewski\SymfonyFormGenerator\Annotation\Form;
use Symfony\Component\Validator\Constraints as Assert;
class ObjectWithMixedMetadata
{
/**
* @var bool
*/
public $propertyBoolean;
/**
* @Assert\Count(max="5")
*/
public $propertyArray;
/**
* @Form\Field("integer", options={"label"="Property Integer"})
*/
public $propertyInteger;
public $propertyDateTime;
public $propertyUndefined;
public function __construct($propertyBoolean, $propertyArray, $propertyInteger, \DateTime $propertyDateTime, $propertyUndefined)
{
$this->propertyBoolean = $propertyBoolean;
$this->propertyArray = $propertyArray;
$this->propertyInteger = $propertyInteger;
$this->propertyDateTime = $propertyDateTime;
$this->propertyUndefined = $propertyUndefined;
}
}
after:, (*3)
$form = $this->get('form_generator')
->generateFormBuilder(ObjectWithMixedMetadata::class)
->getForm();
will have form
equivalent:, (*4)
use Lzakrzewski\SymfonyFormGenerator\Form\Type\GeneratorFormType;
use Lzakrzewski\SymfonyFormGenerator\ObjectWithMixedMetadata;
use Symfony\Component\Form\Forms;
Forms::createFormFactory()->createBuilder()
->create('form', new GeneratorFormType(ObjectWithMixedMetadata::class))
->add('propertyBoolean', 'checkbox')
->add('propertyArray', 'generator_array')
->add('propertyInteger', 'integer')
->add('propertyDateTime', 'generator_datetime')
->add('propertyUndefined', 'generator_string');
generator_array
type extends collection
,
generator_datetime
type extends datetime
,
generator_string
type extends text
., (*5)
generator_*
types are custom form types for better support raw values., (*6)
Documentation
Topics:
- Installation
- Usage
- Custom mapping, (*7)