Automate form building.
Branch | Tools |
---|---|
master |
Use composer:
composer require a2lix/auto-form-bundle
After the successful installation, add/check the bundle registration:
// bundles.php is automatically updated if flex is installed.
// ...
A2lix\AutoFormBundle\A2lixAutoFormBundle::class => ['all' => true],
// ...
There is no minimal configuration, so this part is optional. Full list:
# Create a dedicated a2lix.yaml in config/packages with:
a2lix_auto_form:
excluded_fields: [id, locale, translatable] # [1]
use A2lix\AutoFormBundle\Form\Type\AutoFormType;
...
$builder->add('medias', AutoFormType::class);
use A2lix\AutoFormBundle\Form\Type\AutoFormType;
...
$builder->add('medias', AutoFormType::class, [
'fields' => [ // [2]
'description' => [ // [3.a]
'field_type' => 'textarea', // [4]
'label' => 'descript.', // [4]
'locale_options' => [ // [3.b]
'es' => ['label' => 'descripción'] // [4]
'fr' => ['display' => false] // [4]
]
]
],
'excluded_fields' => ['details'] // [2]
]);
See Demo Bundle for more examples.
docker run --rm --interactive --tty --volume $PWD:/app --user $(id -u):$(id -g) composer install --ignore-platform-reqs
docker run --rm --interactive --tty --volume $PWD:/app --user $(id -u):$(id -g) composer run-script phpunit
docker run --rm --interactive --tty --volume $PWD:/app --user $(id -u):$(id -g) composer run-script cs-fixer
This package is available under the MIT license.