From 9f7ba8fdf7e8300f1a2b57119fc8c613849f85bc Mon Sep 17 00:00:00 2001 From: David ALLIX Date: Tue, 2 Jul 2024 19:40:22 +0200 Subject: [PATCH] Update README.md --- README.md | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c0cdd52..3ef8110 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,77 @@ Automate form building. | --- | --- | | master | [![Build Status][ci_badge]][ci_link] [![Coverage Status][coverage_badge]][coverage_link] | -## Documentation +## Installation -Check out the documentation on the [official website](http://a2lix.fr/bundles/auto-form). +Use composer: + +```bash +composer require a2lix/auto-form-bundle +``` + +After the successful installation, add/check the bundle registration: + +```php +// 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: + +```yaml +# Create a dedicated a2lix.yaml in config/packages with: + +a2lix_auto_form: + excluded_fields: [id, locale, translatable] # [1] +``` + +1. Optional. + +## Usage + +### In a classic formType + +```php +use A2lix\AutoFormBundle\Form\Type\AutoFormType; +... +$builder->add('medias', AutoFormType::class); +``` + +### Advanced examples + +```php +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] +]); +``` + +2. Optional. If set, override the default value from config.yml +3. 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 +4. 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](https://github.com/a2lix/Demo) for more examples. ## Contribution help