agence-adeliom/easy-fields-bundle

为 EasyAdmin 提供一些字段的 Symfony 扩展包

安装次数: 11,239

依赖项: 8

建议者: 0

安全: 0

星标: 11

关注者: 2

分支: 8

开放问题: 7

语言:JavaScript

类型:symfony-bundle

2.0.122 2023-08-03 12:45 UTC

README

Adeliom Quality gate

Easy Fields Bundle

为 Easyadmin 提供一些字段。

版本

使用 Symfony Flex 安装

添加我们的食谱端点

{
  "extra": {
    "symfony": {
      "endpoint": [
        "https://api.github.com/repos/agence-adeliom/symfony-recipes/contents/index.json?ref=flex/main",
        ...
        "flex://defaults"
      ],
      "allow-contrib": true
    }
  }
}

使用 composer 安装

composer require agence-adeliom/easy-fields-bundle

文档

AssociationField

是 EasyAdmin 的 AssociationField 的扩展,允许您创建新对象并从当前页面选择一个。

用法

use Adeliom\EasyFieldsBundle\Admin\Field\AssociationField;

// You have to add this form theme @EasyFields/form/association_widget.html.twig
...
yield AssociationField::new('property', "label");

EnumField

用法

use Adeliom\EasyFieldsBundle\Admin\Field\EnumField;
...
yield EnumField::new('property', "label")
    ->setEnum(YourEnumClass::class);

FormTypeField

该字段是自定义集成,允许您将任何原始表单类型绑定到您的管理界面。

用法

use Adeliom\EasyFieldsBundle\Admin\Field\FormTypeField;
...
yield FormTypeField::new('property', "label", YourFormTypeClass::class)

TranslationField

EasyAdmin 的 A2lix TranslationFormBundle 集成。

用法

use Adeliom\EasyFieldsBundle\Admin\Field\TranslationField;

// You have to add this form theme @EasyFields/form/translations_widget.html.twig
...
yield TranslationField::new('property', "label", [
    'description' => [
        'field_type' => 'textarea',
        'label' => 'descript.',
        'locale_options' => [
            'es' => ['label' => 'descripción']
            'fr' => ['display' => false]
        ]
    ]
])

ChoiceMaskField

是 Sonata 的 ChoiceMaskField 的分支,用于 EasyAdmin。

用法

use Adeliom\EasyFieldsBundle\Admin\Field\ChoiceMaskField;

// You have to add this form theme @EasyFields/form/choice_mask_widget.html.twig
...
yield ChoiceMaskField::new('property', "label")
    ->setChoices([
        'uri' => 'uri',
        'route' => 'route',
    ])
    // Associative array. Describes the fields that are displayed for each choice.
    ->setMap([
        'route' => ['route', 'parameters'],
        'uri' => ['uri'],
    ]);

SortableCollectionField

是 EasyAdmin 的 CollectionField 的扩展,允许您排序条目。

用法

use Adeliom\EasyFieldsBundle\Admin\Field\SortableCollectionField;

// You have to add this form theme @EasyFields/form/sortable_widget.html.twig
...
// NOTE : property can be a *ToMany or an array.
yield SortableCollectionField::new('property', "label")
    ->setEntryType(YourEntryFromType::class)
    ->allowAdd() // Allow to add new entry
    ->allowDelete() // Allow to remove entries
    ->allowDrag()  // Allow to drag entries
    ;

IconField

是图标选择器。

用法

use Adeliom\EasyFieldsBundle\Admin\Field\IconField;

// You have to add this form theme @EasyFields/form/icon_widget.html.twig
...
yield IconField::new('property', "label")
    ->setJsonUrl($url) // Must be a public json file with an array of your icon's classes
    ->setFonts($fonts) // Must be an array of yours fonticon css file
    ->setSelectButtonLabel() // Change label
    ->setCancelButtonLabel()  // Change label
    ->setShowAllButtonLabel()  // Change label
    ->setSearchPlaceholder()  // Change label
    ->setNotResultMessage()  // Change label
    ->setDeleteLabel()
    ;

PositionSortableField

用法

use Adeliom\EasyFieldsBundle\Admin\Field\PositionSortableField;

// You have to add this form theme @EasyFields/form/form-easy-field-position-sortable.html.twig
...
yield PositionSortableField::new('property', "label");

OembedField

要使用此字段,您需要添加特定于包的路由

# config/routes/easy_fields.yaml

easy_fields:
  resource: '@EasyFieldsBundle/Resources/config/routes.xml'
  prefix: /

用法

use Adeliom\EasyFieldsBundle\Admin\Field\OembedField;

// You have to add this form theme @EasyFields/form/oembed_widget.html.twig
...
yield OembedField::new('property', "label");
Twig 渲染
# Get HTML code
{{ property|oembed_html }}

# Get Dimensions
{{ property|oembed_size }}

许可证

MIT

作者