a2lix / auto-form-bundle
自动化表单构建
0.4.7
2024-01-09 18:21 UTC
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-09-02 17:58:03 UTC
README
自动化表单构建。
安装
使用composer
composer require a2lix/auto-form-bundle
安装成功后,添加/检查包注册
// bundles.php is automatically updated if flex is installed. // ... A2lix\AutoFormBundle\A2lixAutoFormBundle::class => ['all' => true], // ...
配置
没有最小配置,因此这部分是可选的。完整列表
# Create a dedicated a2lix.yaml in config/packages with: a2lix_auto_form: excluded_fields: [id, locale, translatable] # [1]
- 可选。
用法
在经典formType中
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] ]);
- 可选。如果设置,将覆盖config.yml中的默认值
- 可选。如果设置,将覆盖字段的自动配置
- [3.a] 可选。 - 对于一个字段,应用于所有区域
- [3.b] 可选。 - 对于字段的特定区域
- 可选。symfony表单的常见选项(max_length,required,trim,read_only,constraints等),添加了'field_type'和'display'选项
附加
示例
查看更多示例,请参阅 Demo Bundle。
贡献帮助
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
许可证
此软件包可在MIT许可证下获得。