a2lix / auto-form-bundle
Automate form building
Installs: 2 712 976
Dependents: 10
Suggesters: 0
Security: 0
Stars: 83
Watchers: 3
Forks: 30
Open Issues: 8
Type:symfony-bundle
Requires
- php: ^8.1
- doctrine/persistence: ^2.0|^3.0
- symfony/config: ^5.4.30|^6.3|^7.0
- symfony/dependency-injection: ^5.4.30|^6.3|^7.0
- symfony/doctrine-bridge: ^5.4.30|^6.3|^7.0
- symfony/form: ^5.4.30|^6.3|^7.0
- symfony/http-kernel: ^5.4.30|^6.3|^7.0
Requires (Dev)
- doctrine/orm: ^2.15
- friendsofphp/php-cs-fixer: ^3.45
- kubawerlos/php-cs-fixer-custom-fixers: ^3.18
- phpstan/phpstan: ^1.10
- rector/rector: ^0.18
- symfony/cache: ^5.4.30|^6.3|^7.0
- symfony/phpunit-bridge: ^5.4.30|^6.3|^7.0
- symfony/validator: ^5.4.30|^6.3|^7.0
- vimeo/psalm: ^5.18
Suggests
- a2lix/translation-form-bundle: For translation form
This package is auto-updated.
Last update: 2024-12-02 18:27:02 UTC
README
Automate form building.
Installation
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], // ...
Configuration
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]
- Optional.
Usage
In a classic formType
use A2lix\AutoFormBundle\Form\Type\AutoFormType; ... $builder->add('medias', AutoFormType::class);
Advanced examples
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] ]);
- Optional. If set, override the default value from config.yml
- Optional. If set, override the auto configuration of fields
- [3.a] Optional. - For a field, applied to all locales
- [3.b] Optional. - For a specific locale of a field
- Optional. Common options of symfony forms (max_length, required, trim, read_only, constraints, ...), which was added 'field_type' and 'display'
Additional
Example
See Demo Bundle for more examples.
Contribution help
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
License
This package is available under the MIT license.