由于某种原因,error_bubbling设置为false不会影响表单行为,并且所有错误都将移至顶部表单。我正在使用symfony 2.4.4。我的代码:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->setErrorBubbling(false);
$builder->add('wrapper', 'thatformbelow', [
'data_class' => get_class(new SomethingElse()),
'property_path' => 'something',
'error_bubbling' => false,
]);
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => get_class(new Something()),
'error_bubbling' => false,
));
}
子窗体
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->setErrorBubbling(false);
$builder
->add('name', 'text', array(
'label' => 'Arr',
'error_bubbling' => false,
));
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'whatever',
'error_bubbling' => false,
));
}
验证
Somethingwrapper:
properties:
wrapper:
- Valid: ~
Myentitysomething:
properties:
name:
- NotBlank:
groups: ['flow_mail_base_create_step1']
- Length:
min: 4
groups: ['flow_mail_base_create_step1']
正如你所看到的,我尝试了很多方法,但都没有用。模板是标准形式()(通过MopaBootstrap),但问题在于映射,而不是显示。
可能是什么原因?
答案 0 :(得分:1)
后来总比没有好,我遇到了同样的问题,原因就在于此 骆驼案件的字段名称。
例如
WRONG
$builder->add('given_name')
CORRECT
$builder->add('givenName') //should match your entity property NOT column