Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Dp\UtilsBundle\Form\Type;
- use Symfony\Component\Form\AbstractType;
- use Symfony\Component\Form\FormBuilder;
- use Symfony\Component\Form\FormBuilderInterface;
- /**
- * GMapAddressType
- *
- * @author Sullivan SENECHAL
- */
- class GMapAddressType extends AbstractType
- {
- public function buildForm(FormBuilderInterface $builder, array $options)
- {
- $builder
- ->add('address', null, array(
- 'required' => true,
- ))
- ->add('locality', 'hidden', array(
- 'required' => false,
- ))
- ->add('country', 'hidden', array(
- 'required' => false
- ))
- ->add('lat', 'hidden', array(
- 'required' => false
- ))
- ->add('lng', 'hidden', array(
- 'required' => false
- ))
- ;
- }
- public function getDefaultOptions(array $options)
- {
- return array(
- 'virtual' => true, // Ici nous précisons que notre FormType est un champ virtuel
- );
- }
- public function getName()
- {
- return 'gmap_address'; // Le nom de notre champ, il sera utilisé après
- }
- }
- ?>
- --------------------------------------------------------------------------------------------------
- <?php
- namespace Dp\ProdBundle\Form;
- use Symfony\Component\Form\AbstractType;
- use Symfony\Component\Form\FormBuilderInterface;
- use Symfony\Component\OptionsResolver\OptionsResolverInterface;
- use Symfony\Component\Form\Extension\Core\Type\CountryType;
- class ProducteurType extends AbstractType
- {
- public function buildForm(FormBuilderInterface $builder, array $options)
- {
- $builder
- ->add('genre', 'choice', array(
- 'choices' => array(
- 'M' => 'M',
- 'F' => 'F',
- ),
- 'required' => false,
- 'empty_data' => 'M',
- 'expanded' => 'true'
- ))
- ->add('nom')
- ->add('prenom')
- ->add('portable', 'text', array('required' => false))
- ->add('email', 'hidden')
- ->add('nom_societe', 'text', array('required' => false))
- ->add('kbis', 'text', array('required' => false))
- ->add('rcs', 'text', array('required' => false))
- ->add('web', 'text', array('required' => false))
- ->add('address', 'gmap_address', array(
- 'data_class' => 'Dp\ProdBundle\Entity\Producteur',))
- //->add('address')
- //->add('cp')
- //->add('locality')
- //->add('country','country',array(
- // 'preferred_choices' => array('FR')))
- ->add('tel_societe', 'text', array('required' => false))
- ->add('presentation')
- ->add('image', new ImageType(), array('required' => false))
- ;
- }
- public function setDefaultOptions(OptionsResolverInterface $resolver)
- {
- $resolver->setDefaults(array(
- 'data_class' => 'Dp\ProdBundle\Entity\Producteur'
- ));
- }
- public function getName()
- {
- return 'dp_prodbundle_producteurtype';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement