Created
February 1, 2011 16:22
-
-
Save webmozart/806089 to your computer and use it in GitHub Desktop.
Please vote!
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
a) Importing the namespace only | |
<?php | |
use Symfony\Component\Form | |
class ContactForm extends Form\Form | |
{ | |
protected function configure() | |
{ | |
$this->add(new Form\TextField('subject', array( | |
'max_length' => 100, | |
))); | |
$this->add(new Form\TextareaField('message')); | |
$this->add(new Form\EmailField('sender')); | |
$this->add(new Form\CheckboxField('ccmyself', array( | |
'required' => false, | |
))); | |
} | |
} | |
?> | |
b) Importing all classes separately | |
<?php | |
use Symfony\Component\Form\Form | |
use Symfony\Component\Form\TextField | |
use Symfony\Component\Form\TextareaField | |
use Symfony\Component\Form\EmailField | |
use Symfony\Component\Form\CheckboxField | |
class ContactForm extends Form | |
{ | |
protected function configure() | |
{ | |
$this->add(new TextField('subject', array( | |
'max_length' => 100, | |
))); | |
$this->add(new TextareaField('message')); | |
$this->add(new EmailField('sender')); | |
$this->add(new CheckboxField('ccmyself', array( | |
'required' => false, | |
))); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
a) is more conscise, and when building form we add, remove field so namespaces may increase as we forgot to remove unused one