Advertisement
Guest User

Untitled

a guest
Feb 5th, 2013
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. <?php
  2. namespace Dp\UtilsBundle\Form\Type;
  3.  
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\FormBuilder;
  6. use Symfony\Component\Form\FormBuilderInterface;
  7.  
  8. /**
  9. * GMapAddressType
  10. *
  11. * @author Sullivan SENECHAL
  12. */
  13. class GMapAddressType extends AbstractType
  14. {
  15. public function buildForm(FormBuilderInterface $builder, array $options)
  16. {
  17. $builder
  18. ->add('address', null, array(
  19. 'required' => true,
  20. ))
  21. ->add('locality', 'hidden', array(
  22. 'required' => false,
  23. ))
  24. ->add('country', 'hidden', array(
  25. 'required' => false
  26. ))
  27. ->add('lat', 'hidden', array(
  28. 'required' => false
  29. ))
  30. ->add('lng', 'hidden', array(
  31. 'required' => false
  32. ))
  33. ;
  34. }
  35.  
  36. public function getDefaultOptions(array $options)
  37. {
  38. return array(
  39. 'virtual' => true, // Ici nous précisons que notre FormType est un champ virtuel
  40. );
  41. }
  42.  
  43. public function getName()
  44. {
  45. return 'gmap_address'; // Le nom de notre champ, il sera utilisé après
  46. }
  47. }
  48.  
  49. ?>
  50. --------------------------------------------------------------------------------------------------
  51. <?php
  52.  
  53. namespace Dp\ProdBundle\Form;
  54.  
  55. use Symfony\Component\Form\AbstractType;
  56. use Symfony\Component\Form\FormBuilderInterface;
  57. use Symfony\Component\OptionsResolver\OptionsResolverInterface;
  58. use Symfony\Component\Form\Extension\Core\Type\CountryType;
  59.  
  60. class ProducteurType extends AbstractType
  61. {
  62. public function buildForm(FormBuilderInterface $builder, array $options)
  63. {
  64. $builder
  65. ->add('genre', 'choice', array(
  66. 'choices' => array(
  67. 'M' => 'M',
  68. 'F' => 'F',
  69. ),
  70. 'required' => false,
  71. 'empty_data' => 'M',
  72. 'expanded' => 'true'
  73. ))
  74. ->add('nom')
  75. ->add('prenom')
  76. ->add('portable', 'text', array('required' => false))
  77. ->add('email', 'hidden')
  78. ->add('nom_societe', 'text', array('required' => false))
  79. ->add('kbis', 'text', array('required' => false))
  80. ->add('rcs', 'text', array('required' => false))
  81. ->add('web', 'text', array('required' => false))
  82. ->add('address', 'gmap_address', array(
  83. 'data_class' => 'Dp\ProdBundle\Entity\Producteur',))
  84. //->add('address')
  85. //->add('cp')
  86. //->add('locality')
  87. //->add('country','country',array(
  88. // 'preferred_choices' => array('FR')))
  89. ->add('tel_societe', 'text', array('required' => false))
  90. ->add('presentation')
  91. ->add('image', new ImageType(), array('required' => false))
  92. ;
  93. }
  94.  
  95. public function setDefaultOptions(OptionsResolverInterface $resolver)
  96. {
  97. $resolver->setDefaults(array(
  98. 'data_class' => 'Dp\ProdBundle\Entity\Producteur'
  99. ));
  100. }
  101.  
  102. public function getName()
  103. {
  104. return 'dp_prodbundle_producteurtype';
  105. }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement