PHP code example of lzakrzewski / symfony-form-generator
1. Go to this page and download the library: Download lzakrzewski/symfony-form-generator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lzakrzewski / symfony-form-generator example snippets
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;
}
}
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');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.