本文介绍了FOSUser Bundle将PlaceHolder添加到表单元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解到,当您覆盖FOSUser Bundle表单时,您将遵循以下结构;

I understand that when you are overriding FOSUser Bundle Forms, you follow this structure;

{{ form_widget(form.plainPassword.first, { 'attr': {'class': 'myformclass'} }) }}

我还想将PlaceHolder选项添加到表单元素中.我该怎么做?

I also want to add PlaceHolder option to my form element.. How can i do that?

所以看起来像这样;

<input class="myformclass" placeholder="Password" type="password" id="password" name="_password" required="required" />

推荐答案

{{ form_widget(form.plainPassword.first, { 'attr': {'class': 'myformclass', 'placeholder': 'Password', 'id': password'}}) }}

字段名称取决于您的表单名称

Field name depends on your form name

它将被命名为fosuser捆绑包注册表格

it will like be named this for fosuser bundle register form

fos_user_registration_form[plainPassword][password]

ID为

fos_user_registration_form_plainPassword_password

您可以像示例中那样覆盖"id"

You can override "id" like written in my example

必填项和名称选项在表单类中定义

Required and name options are defined in the form class

这篇关于FOSUser Bundle将PlaceHolder添加到表单元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 13:59