Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace ITW\ContactBundle\Form;
- use Symfony\Component\Form\AbstractType;
- use Symfony\Component\Form\FormBuilderInterface;
- use Symfony\Component\OptionsResolver\OptionsResolverInterface;
- use ITW\ContactBundle\Entity\Contact;
- class ContactType extends AbstractType
- {
- /**
- * @param FormBuilderInterface $builder
- * @param array $options
- */
- public function buildForm(FormBuilderInterface $builder, array $options)
- {
- $builder
- ->add('name','text',array())
- ->add('code','text',array())
- ->add('relation','choice', array('required' => true,
- 'choices' => array(
- Contact::REL_CUSTOMER => 'Customer',
- Contact::REL_SUPPLIER => 'Supplier',
- Contact::REL_FRIEND => 'Friend',
- Contact::REL_COMPETETOR => 'COMPETITOR',
- Contact::REL_SERVICE => 'SERVICE',
- Contact::REL_OTHER => 'OTHER',
- ))
- ->add('jobtype','text',array())
- ->add('machinetype','text',array())
- ->add('description','textarea',array())
- ->add('country','country',array('required' => true,'empty_value' => 'Choose ...'))
- ->add('city','text',array('required' => true))
- ->add('address1','textarea',array('required' => true))
- ->add('address2','textarea',array('required' => false))
- ->add('fax','text',array('required' => false))
- ->add('emailweb','text',array('required' => false))
- ->add('tels','collection', array(
- 'required' => false,
- 'prototype'=>true,
- 'type'=> 'text',
- 'allow_add'=>true,
- 'allow_delete' => true,
- 'delete_empty'=>true))
- ->add('persons', 'collection', array(
- 'type' => new PersonType(),
- 'allow_add' => true,
- 'allow_delete' => true,
- ));
- ;
- }
- /**
- * @param OptionsResolverInterface $resolver
- */
- public function setDefaultOptions(OptionsResolverInterface $resolver)
- {
- $resolver->setDefaults(array(
- 'data_class' => 'ITW\ContactBundle\Entity\Contact'
- ));
- }
- /**
- * @return string
- */
- public function getName()
- {
- return 'itw_contactbundle_contact';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment