我有一个表格集合。当我渲染我的结果时,我有每个表单的 div 和标签(当我使用原型添加表单时,这些也被添加)第一个表单是
namespace Webwall\CamBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class SocialType extends AbstractType {
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder
->add('account')
;
}
public function setDefaultOptions(OptionsResolverInterface $resolver) {
$resolver->setDefaults(array(
'data_class' => 'Webwall\CamBundle\Entity\Social',
));
}
public function getName() {
return 'social';
}
}
“主要形式”是
namespace Webwall\CamBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class MediaType extends AbstractType {
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder
->add('socials', 'collection', array(
'type' => new SocialType(),
'allow_add' => true,
))
;
}
public function setDefaultOptions(OptionsResolverInterface $resolver) {
$resolver->setDefaults(array(
'data_class' => 'Webwall\CamBundle\Entity\Media'
));
}
public function getName() {
return 'foto';
}
}
在我的树枝上
<div id="form_foto">
{{ form_errors(form) }}
{{ form_rest(form) }}
在我的 dom 我有这个
<div><label class="required">Socials</label><div id="foto_socials" data-prototype=""><div><label class="required">0</label>
为什么我有这个默认的 div?谢谢!