Professional Documents
Culture Documents
Forms en
Forms en
COMPONENT Template
Domain objects
file that renders a form or a field in HTML
an object a form uses to populate default values and where submitted data is written
PHP
FIELDS BirthdayField
CheckboxField
FileField
HiddenField
PercentField
RepeatedField
// src/Acme/HelloBundle/Contact/ContactForm.php
namespace Acme\HelloBundle\Contact;
ChoiceField IntegerField TextField
CollectionField LanguageField TextareaField use Symfony\Component\Form\Form;
use Symfony\Component\Form\TextField;
CountryField LocaleField TimeField use Symfony\Component\Form\TextareaField;
DateField MoneyField TimezoneField use Symfony\Component\Form\CheckboxField;
DateTimeField NumberField UrlField
class ContactForm extends Form {
EntityChoiceField PasswordField protected function configure() {
PHP $this->add(new TextField('subject',
array( 'max_length' => 100, )));
use Symfony\Component\Form\TextField $this->add(new TextareaField('message'));
FIELD OPTIONS data
required $field = new TextField('name',
$this->add(new TextField('sender'));
$this->add(new CheckboxField('ccmyself',
disabled array( array( 'required' => false, )));
'data' => 'Custom default...', }
trim 'property_path' => 'token', }
property_path ));
Twig PHP
echo $view['form']->render($form['title'],
{{ form_field(form.title, { 'class': 'important' }) }}
array('class' => 'important' ))
Twig PHP
{{ form_label(form.title) }} echo $view['form']->label($form['title']);
Twig PHP
PROTOTYPING <form action="#" {{ form_enctype(form) }} <form action="#" <?php echo $view['form']->
method="post"> enctype($form) ?> method="post">
Render the form {{ form_field(form) }} <?php echo $view['form']->render($form) ?>
<input type="submit" /> <input type="submit" />
(all fields) </form> </form>
http://symfony.com http://andreiabohner.wordpress.com