4r1y4n

Untitled

Nov 7th, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.31 KB | None | 0 0
  1. <?php
  2.  
  3. namespace ITW\ContactBundle\Form;
  4.  
  5. use Symfony\Component\Form\AbstractType;
  6. use Symfony\Component\Form\FormBuilderInterface;
  7. use Symfony\Component\OptionsResolver\OptionsResolverInterface;
  8. use ITW\ContactBundle\Entity\Contact;
  9.  
  10. class ContactType 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','text',array())
  20.             ->add('code','text',array())
  21.             ->add('relation','choice', array('required'  => true,
  22.                     'choices' => array(
  23.                             Contact::REL_CUSTOMER => 'Customer',
  24.                             Contact::REL_SUPPLIER => 'Supplier',
  25.                             Contact::REL_FRIEND => 'Friend',
  26.                             Contact::REL_COMPETETOR => 'COMPETITOR',
  27.                             Contact::REL_SERVICE => 'SERVICE',
  28.                             Contact::REL_OTHER => 'OTHER',
  29.                     ))
  30.             ->add('jobtype','text',array())
  31.             ->add('machinetype','text',array())
  32.             ->add('description','textarea',array())
  33.             ->add('country','country',array('required'  => true,'empty_value' => 'Choose ...'))
  34.             ->add('city','text',array('required'  => true))
  35.             ->add('address1','textarea',array('required'  => true))
  36.             ->add('address2','textarea',array('required'  => false))
  37.             ->add('fax','text',array('required'  => false))
  38.             ->add('emailweb','text',array('required'  => false))
  39.             ->add('tels','collection', array(
  40.                     'required'  => false,          
  41.                     'prototype'=>true,
  42.                     'type'=> 'text',
  43.                     'allow_add'=>true,
  44.                     'allow_delete' => true,
  45.                     'delete_empty'=>true))
  46.             ->add('persons', 'collection', array(
  47.                     'type' => new PersonType(),
  48.                     'allow_add'    => true,
  49.                     'allow_delete' => true,
  50.                        
  51.             ));
  52.                        
  53.         ;
  54.     }
  55.    
  56.     /**
  57.      * @param OptionsResolverInterface $resolver
  58.      */
  59.     public function setDefaultOptions(OptionsResolverInterface $resolver)
  60.     {
  61.         $resolver->setDefaults(array(
  62.             'data_class' => 'ITW\ContactBundle\Entity\Contact'
  63.         ));
  64.     }
  65.  
  66.     /**
  67.      * @return string
  68.      */
  69.     public function getName()
  70.     {
  71.         return 'itw_contactbundle_contact';
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment