a2lix/auto-form-bundle

自动化表单构建

安装次数: 2,484,991

依赖关系: 10

建议者: 0

安全性: 0

星标: 83

关注者: 3

分支: 29

开放问题: 9

类型:symfony-bundle

0.4.7 2024-01-09 18:21 UTC

This package is auto-updated.

Last update: 2024-09-02 17:58:03 UTC


README

自动化表单构建。

Latest Stable Version Latest Unstable Version License

Total Downloads Monthly Downloads Daily Downloads

安装

使用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]
  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]
]);
  1. 可选。如果设置,将覆盖config.yml中的默认值
  2. 可选。如果设置,将覆盖字段的自动配置
    • [3.a] 可选。 - 对于一个字段,应用于所有区域
    • [3.b] 可选。 - 对于字段的特定区域
  3. 可选。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许可证下获得。