Symfony4 Element legend not allowed as child of element div in this context

问题: Symfony is generating a W3C error and I don't know how to resolve it : Element legend not allowed as child of element div in this context here is the HTML line : <div...

问题:

Symfony is generating a W3C error and I don't know how to resolve it : Element legend not allowed as child of element div in this context

here is the HTML line : <div class="form-group row"><legend class="col-form-label col-sm-2 col-form-label required">Date de naissance</legend><div class="col-sm-10"><div id="lessee_birthday" class="form-inline"><div class="sr-only"> I think it's generated by the formType

$builder
        ->add('civility', ChoiceType::class, [
            'label' => 'Civilite',
            'choices' => [
                'Mr' => 'Mr',
                'Mme' => 'Mme',
                'Mlle' => 'Mlle',
            ]
        ])
        ->add('name', TextType::class, ['label' => 'Prénom'])
        ->add('lastname', TextType::class, ['label' => 'Nom'])
        ->add('birthday', BirthdayType::class, ['label' => 'Date de naissance']) //here is the problem
        ->add('placeOfBirth', TextType::class, ['label' => 'Lieu de naissance'])
        ->add('email', EmailType::class, ['label' => 'Adresse email'])
        ->add('phoneNumber', TelType::class, ['label' => 'Numéro de telephone'])
    ;

回答1:

According to the specification <legend> tags belong directly underneath <fieldset> tags. You cannot mix them with <div> tags.

So you have to change in your templates how the BirthdayType field is rendered. Have a look at How to Customize Form Rendering in Symfony.

  • 发表于 2019-03-08 20:52
  • 阅读 ( 258 )
  • 分类:sof

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除