SHARE
TWEET

MoviePersonForm

a guest Oct 4th, 2017 42 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public function buildForm(FormBuilderInterface $builder, array $options)
  2.     {
  3.         $builder
  4.             ->add('movie_name')
  5.             ->add('movie_year', IntegerType::class)
  6.             ->add('movie_description', TextareaType::class, array(
  7.                 'required'   => false,
  8.                 'empty_data' => '',
  9.             ))
  10.             ->add('role_name', ChoiceType::class, array(
  11.                 'placeholder' => 'Choose role',
  12.                 'choices' => array(
  13.                     'Actor' => 'actor',
  14.                     'Director' => 'director',
  15.                     'Writer' => 'writer')))
  16.             ->add('person_name', EntityType::class, array(
  17.                 'class' => Person::class,
  18.                 'placeholder' => 'Choose person',
  19.                 'query_builder' => function (EntityRepository $er) {
  20.                     return $er->createQueryBuilder('p')
  21.                         ->orderBy('p.name', 'ASC');
  22.                 },
  23.                 'choice_label' => 'name',
  24.             ));
  25.     }
  26.  
  27.     public function configureOptions(OptionsResolver $resolver)
  28.     {
  29.         $resolver->setDefaults([
  30.             'data_class' => 'AppBundle\Form\Model\MoviePersonModel'
  31.         ]);
  32.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top