Created
September 18, 2012 08:59
-
-
Save soullivaneuh/3742134 to your computer and use it in GitHub Desktop.
Gmap Address Type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Your\UtilsBundle\Form\Type; | |
use Symfony\Component\Form\AbstractType; | |
use Symfony\Component\Form\FormBuilder; | |
use Symfony\Component\Form\FormBuilderInterface; | |
use Doctrine\Common\Persistence\ObjectManager; | |
/** | |
* GMapAddressType | |
* | |
* @author Sullivan SENECHAL <[email protected]> | |
*/ | |
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, | |
); | |
} | |
public function getName() | |
{ | |
return 'gmap_address'; | |
} | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Your\MainBundle\Form\Type; | |
use Symfony\Component\Form\AbstractType; | |
use Symfony\Component\Form\FormBuilder; | |
/** | |
* ParkFormType | |
* | |
* @author Sullivan SENECHAL <[email protected]> | |
*/ | |
class ParkFormType extends AbstractType | |
{ | |
public function buildForm(FormBuilder $builder, array $options) | |
{ | |
$builder->add('name') | |
->add('address', 'gmap_address') | |
; | |
} | |
public function getDefaultOptions(array $options) | |
{ | |
return array( | |
'data_class' => 'Your\MainBundle\Entity\Park', | |
); | |
} | |
public function getName() | |
{ | |
return 'park'; | |
} | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" ?> | |
<container xmlns="http://symfony.com/schema/dic/services" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | |
<parameters> | |
<parameter key="form.type.gmap_address.class">Your\UtilsBundle\Form\Type\GMapAddressType</parameter> | |
</parameters> | |
<services> | |
<service id="form.type.gmap_address" class="%form.type.gmap_address.class%"> | |
<tag name="form.type" alias="gmap_address" /> | |
</service> | |
</services> | |
</container> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment