我有一张要注册的表格:
public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
$builder->add('tel');
$builder->add('telvisible');
}
显示此字段后:
<input type="checkbox" id="fos_user_registration_form_telvisible" name="fos_user_registration_form[telvisible]" value="1">
但我想要展示:
<input type="checkbox" id="fos_user_registration_form_telvisible" name="telvisible" value="1">
答案 0 :(得分:1)
要从名称中删除类型名称,您需要有两个解决方案:
getName
或getBlockPrefix
实施中返回null。public function getBlockPrefix() { return null; }
$form = $this->get('form.factory') ->createNamedBuilder(null, 'form', $address) ->add('address', 'text');