Answer the question
In order to leave comments, you need to log in
How to remove empty fields from bootstrap collection?
Can you please tell me how to delete empty fields when using bootstrap collection? The delete empty option is enabled.
class HostType extends BaseType
{
public function buildForm(FormBuilderInterface $builder,array $options)
{
$builder->add('username','text',array('label'=>'Name'))
->add('email','text')
->add('about',null,array('label'=>'About host'))
->add('picture','iphp_file')
->add('videos','bootstrap_collection',array(
'type'=>new HostVideoType(),
'allow_add'=>true,
'allow_delete'=>true,
'cascade_validation' => true,
'delete_empty'=>true,
'add_button_text' => 'Add video to host',
'delete_button_text' => 'Delete video from host',
));
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'iCliqueLive\HostBundle\Entity\Host',
'validation_groups' => array('addHost'),
'cascade_validation'=>true,
));
}
public function getName()
{
return 'host';
}
}
Answer the question
In order to leave comments, you need to log in
Set by_reference to false and write methods addVideo, removeVideo instead of setVideos
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question