我很清楚创建自定义类型类(例如 TagType)
class TagType extends AbstractType
{
/**
* @var EntityManagerInterface
*/
private $entityManager;
public function __construct(EntityManagerInterface $entityManager)
{
$this->entityManager = $entityManager;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->addModelTransformer(new CollectionToArrayTransformer(), true)
->addModelTransformer(new StringToArrayTransformer($this->entityManager), true);
}
public function getParent()
{
return TextType::class;
}
}
但是如何使它适用于 Easy Admin 3?我已经尝试过像这样的东西,但没有什么能真正帮助我实现自定义类型
public function configureFields(string $pageName): iterable
{
return [
AssociationField::new('tags')->setFormType(TagType::class)
];
}
将不胜感激任何有帮助的东西,谢谢!