Skip to content

Instantly share code, notes, and snippets.

@webmozart
Created February 1, 2011 16:22
Show Gist options
  • Save webmozart/806089 to your computer and use it in GitHub Desktop.
Save webmozart/806089 to your computer and use it in GitHub Desktop.
Please vote!
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,
)));
}
}
?>
@brikou
Copy link

brikou commented Apr 4, 2011

a) is more conscise, and when building form we add, remove field so namespaces may increase as we forgot to remove unused one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment