Created
May 5, 2012 05:54
-
-
Save coreymcmahon/2600205 to your computer and use it in GitHub Desktop.
Defining a Symfony form in a separate class - http://www.symfonycentral.com
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 | |
| // src/MyCompany/BlogBundle/Form/Type/ArticleType.php | |
| namespace MyCompany\BlogBundle\Form\Type; | |
| use Symfony\Component\Form\AbstractType; | |
| use Symfony\Component\Form\FormBuilder; | |
| class ArticleType extends AbstractType | |
| { | |
| public function buildForm(FormBuilder $builder, array $options) | |
| { | |
| $builder->add('title', 'text'); | |
| $builder->add('body', 'textarea'); | |
| } | |
| public function getName() | |
| { | |
| /* The name should be a unique identifier for the form */ | |
| return 'article'; | |
| } | |
| public function getDefaultOptions(array $options) | |
| { | |
| /* If this form corresponds to an Entity, we should include it here */ | |
| return array( | |
| 'data_class' => 'MyCompany\BlogBundle\Entity\Article', | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment