Advertisement
Guest User

Untitled

a guest
Jul 24th, 2014
552
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. <?php
  2.  
  3. namespace My\Bundle\Form\Post;
  4.  
  5. use Symfony\Component\Form\AbstractType;
  6. use Symfony\Component\Form\FormBuilderInterface;
  7. use Symfony\Component\OptionsResolver\OptionsResolverInterface;
  8. use My\Bundle\Form\Post\GalleryImageType;
  9.  
  10. class GalleryType extends AbstractType
  11. {
  12.         /**
  13.      * @param FormBuilderInterface $builder
  14.      * @param array $options
  15.      */
  16.     public function buildForm(FormBuilderInterface $builder, array $options)
  17.     {
  18.         $builder
  19.             ->add('name')
  20.             ->add('images', 'collection', array(
  21.                 'type' => new GalleryImageType()
  22.             ))
  23.         ;
  24.     }
  25.    
  26.     /**
  27.      * @param OptionsResolverInterface $resolver
  28.      */
  29.     public function setDefaultOptions(OptionsResolverInterface $resolver)
  30.     {
  31.         $resolver->setDefaults(array(
  32.             'data_class' => 'My\Bundle\Entity\Post\Gallery'
  33.         ));
  34.     }
  35.  
  36.     /**
  37.      * @return string
  38.      */
  39.     public function getName()
  40.     {
  41.         return 'post_gallery';
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement