Last active
August 29, 2015 13:56
-
-
Save bchoquet-heliopsis/9113340 to your computer and use it in GitHub Desktop.
This file contains 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 | |
//src/Acme/FormBundle/Forms/CustomFormType.php | |
namespace Acme\FormBundle\Forms; | |
use Symfony\Component\Form\AbstractType; | |
use Symfony\Component\Form\FormBuilderInterface; | |
use Symfony\Component\OptionsResolver\OptionsResolverInterface; | |
use Acme\FormBundle\Entity\FormData; | |
class CustomFormType extends AbstractType | |
{ | |
public function getName() | |
{ | |
return 'acme_custom_form'; | |
} | |
public function buildForm( FormBuilderInterface $builder, array $options ) | |
{ | |
$builder->add( 'field1', 'text', array( 'required' => true, 'label' => 'My Custom Field' ); | |
$builder->add( 'field2', 'choice', array( 'label' => 'My Custom Select', 'choices' => array( 1, 2, 3 ) ); | |
$builder->add( 'submit', 'submit', array( 'label' => 'Go!' ); | |
} | |
public function setDefaultOptions(OptionsResolverInterface $resolver) | |
{ | |
$resolver->setDefaults( array( | |
'data_class' => 'Acme\FormBundle\Entity\FormData' | |
) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment