symfony 2 - “错误选项”0“不存在。”
symfony 2 - “error The option ”0“ does not exist.”
我正在使用 a2lix/TranslationFormBundle 并且我正在尝试添加 EntityType 字段。
我在尝试构建表单时遇到此错误:
The option "0" does not exist. Known options are: "action", "attr", "auto_initialize", "block_name", "by_reference", "compound", "csrf_field_name", "csrf_message", "csrf_protection", "csrf_provider", "csrf_token_id", "csrf_token_manager", "data", "data_class", "disabled", "empty_data", "error_bubbling", "inherit_data", "intention", "label", "label_attr", "label_format", "mapped", "max_length", "method", "pattern", "post_max_size_message", "property_path", "read_only", "required", "translation_domain", "trim", "virtual"
这是我的 FormType
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use A2lix\TranslationFormBundle\Form\Type\TranslationsType;
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('tag', TextType::class)
->add('translations', TranslationsType::class, [
'fields' => [
'promotion' => ['field_type' => EntityType::class, [
'class' => 'AdminBundle:Promotion',
'choice_label' => 'getName'
] ]
]
])
->add('Save', SubmitType::class)
;
}
当我在 TranslationType 字段之外使用 EntityType 字段时,它的工作。但是当我在 TranslationType 中使用它时,它不会。
如有任何帮助,我们将不胜感激
我在尝试在 A2lix 表单中自定义 CKEditor 工具栏时遇到了类似的错误。
解决方案并不容易找到。不是为 class 的选项添加新数组,而是像这样集成:
$builder
->add('tag', TextType::class)
->add('translations', TranslationsType::class, [
'fields' => [
'promotion' => ['field_type' => EntityType::class, [
'class' => 'AdminBundle:Promotion',
'choice_label' => 'getName'
] ]
]
])
你应该尝试这样写(即将选项直接放在 'promotion' 的数组中):
$builder
->add('tag', TextType::class)
->add('translations', TranslationsType::class, [
'fields' => [
'promotion' => ['field_type' => EntityType::class,
'class' => 'AdminBundle:Promotion',
'choice_label' => 'getName',
]
]
])
我正在使用 a2lix/TranslationFormBundle 并且我正在尝试添加 EntityType 字段。
我在尝试构建表单时遇到此错误:
The option "0" does not exist. Known options are: "action", "attr", "auto_initialize", "block_name", "by_reference", "compound", "csrf_field_name", "csrf_message", "csrf_protection", "csrf_provider", "csrf_token_id", "csrf_token_manager", "data", "data_class", "disabled", "empty_data", "error_bubbling", "inherit_data", "intention", "label", "label_attr", "label_format", "mapped", "max_length", "method", "pattern", "post_max_size_message", "property_path", "read_only", "required", "translation_domain", "trim", "virtual"
这是我的 FormType
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use A2lix\TranslationFormBundle\Form\Type\TranslationsType;
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('tag', TextType::class)
->add('translations', TranslationsType::class, [
'fields' => [
'promotion' => ['field_type' => EntityType::class, [
'class' => 'AdminBundle:Promotion',
'choice_label' => 'getName'
] ]
]
])
->add('Save', SubmitType::class)
;
}
当我在 TranslationType 字段之外使用 EntityType 字段时,它的工作。但是当我在 TranslationType 中使用它时,它不会。
如有任何帮助,我们将不胜感激
我在尝试在 A2lix 表单中自定义 CKEditor 工具栏时遇到了类似的错误。
解决方案并不容易找到。不是为 class 的选项添加新数组,而是像这样集成:
$builder
->add('tag', TextType::class)
->add('translations', TranslationsType::class, [
'fields' => [
'promotion' => ['field_type' => EntityType::class, [
'class' => 'AdminBundle:Promotion',
'choice_label' => 'getName'
] ]
]
])
你应该尝试这样写(即将选项直接放在 'promotion' 的数组中):
$builder
->add('tag', TextType::class)
->add('translations', TranslationsType::class, [
'fields' => [
'promotion' => ['field_type' => EntityType::class,
'class' => 'AdminBundle:Promotion',
'choice_label' => 'getName',
]
]
])