Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace AppBundle\Form;
- use Symfony\Component\Form\AbstractType;
- use Symfony\Component\Form\FormBuilderInterface;
- use Symfony\Component\OptionsResolver\OptionsResolver;
- use Symfony\Component\Form\Extension\Core\Type\TextType;
- use Symfony\Bridge\Doctrine\Form\Type\EntityType;
- use Symfony\Component\Form\Extension\Core\Type\CollectionType;
- class ApplicationType extends AbstractType
- {
- /**
- * @param FormBuilderInterface $builder
- * @param array $options
- */
- public function buildForm(FormBuilder $builder, array $options)
- {
- $builder
- ->add('firstname', TextType::class, array(
- 'label'=>'',
- 'attr'=>array(
- 'class'=>'gui-input',
- 'placeholder'=>'',
- 'dir'=>'ltr'
- )
- )
- )
- ->add('lastname', TextType::class, array(
- 'label'=>'',
- 'attr'=>array(
- 'class'=>'gui-input',
- 'placeholder'=>'',
- 'dir'=>'ltr'
- )
- )
- )
- ->add('skills', CollectionType::class, array(
- 'entry_type' => SkillType::class,
- 'allow_add' => true, // to allow adding items dynamically
- 'allow_delete' => true,
- 'by_reference' => false,
- 'prototype' => true,
- 'prototype_name'=> 'skill__name__',
- )
- );
- }
- /**
- * @param OptionsResolver $resolver
- */
- public function configureOptions(OptionsResolver $resolver)
- {
- $resolver->setDefaults(array(
- 'data_class' => 'ModelBundle\Entity\Application'
- ));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement