|
18 | 18 | *
|
19 | 19 | * Use this class to conveniently create new form factories:
|
20 | 20 | *
|
21 |
| - * <code> |
22 |
| - * use Symfony\Component\Form\Forms; |
| 21 | + * use Symfony\Component\Form\Forms; |
23 | 22 | *
|
24 |
| - * $formFactory = Forms::createFormFactory(); |
| 23 | + * $formFactory = Forms::createFormFactory(); |
25 | 24 | *
|
26 |
| - * $form = $formFactory->createBuilder() |
27 |
| - * ->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType') |
28 |
| - * ->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType') |
29 |
| - * ->add('age', 'Symfony\Component\Form\Extension\Core\Type\IntegerType') |
30 |
| - * ->add('gender', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( |
31 |
| - * 'choices' => array('Male' => 'm', 'Female' => 'f'), |
32 |
| - * )) |
33 |
| - * ->getForm(); |
34 |
| - * </code> |
| 25 | + * $form = $formFactory->createBuilder() |
| 26 | + * ->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType') |
| 27 | + * ->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType') |
| 28 | + * ->add('age', 'Symfony\Component\Form\Extension\Core\Type\IntegerType') |
| 29 | + * ->add('gender', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( |
| 30 | + * 'choices' => array('Male' => 'm', 'Female' => 'f'), |
| 31 | + * )) |
| 32 | + * ->getForm(); |
35 | 33 | *
|
36 | 34 | * You can also add custom extensions to the form factory:
|
37 | 35 | *
|
38 |
| - * <code> |
39 |
| - * $formFactory = Forms::createFormFactoryBuilder() |
40 |
| - * ->addExtension(new AcmeExtension()) |
41 |
| - * ->getFormFactory(); |
42 |
| - * </code> |
| 36 | + * $formFactory = Forms::createFormFactoryBuilder() |
| 37 | + * ->addExtension(new AcmeExtension()) |
| 38 | + * ->getFormFactory(); |
43 | 39 | *
|
44 | 40 | * If you create custom form types or type extensions, it is
|
45 | 41 | * generally recommended to create your own extensions that lazily
|
46 | 42 | * load these types and type extensions. In projects where performance
|
47 | 43 | * does not matter that much, you can also pass them directly to the
|
48 | 44 | * form factory:
|
49 | 45 | *
|
50 |
| - * <code> |
51 |
| - * $formFactory = Forms::createFormFactoryBuilder() |
52 |
| - * ->addType(new PersonType()) |
53 |
| - * ->addType(new PhoneNumberType()) |
54 |
| - * ->addTypeExtension(new FormTypeHelpTextExtension()) |
55 |
| - * ->getFormFactory(); |
56 |
| - * </code> |
| 46 | + * $formFactory = Forms::createFormFactoryBuilder() |
| 47 | + * ->addType(new PersonType()) |
| 48 | + * ->addType(new PhoneNumberType()) |
| 49 | + * ->addTypeExtension(new FormTypeHelpTextExtension()) |
| 50 | + * ->getFormFactory(); |
57 | 51 | *
|
58 | 52 | * Support for the Validator component is provided by ValidatorExtension.
|
59 | 53 | * This extension needs a validator object to function properly:
|
60 | 54 | *
|
61 |
| - * <code> |
62 |
| - * use Symfony\Component\Validator\Validation; |
63 |
| - * use Symfony\Component\Form\Extension\Validator\ValidatorExtension; |
| 55 | + * use Symfony\Component\Validator\Validation; |
| 56 | + * use Symfony\Component\Form\Extension\Validator\ValidatorExtension; |
64 | 57 | *
|
65 |
| - * $validator = Validation::createValidator(); |
66 |
| - * $formFactory = Forms::createFormFactoryBuilder() |
67 |
| - * ->addExtension(new ValidatorExtension($validator)) |
68 |
| - * ->getFormFactory(); |
69 |
| - * </code> |
| 58 | + * $validator = Validation::createValidator(); |
| 59 | + * $formFactory = Forms::createFormFactoryBuilder() |
| 60 | + * ->addExtension(new ValidatorExtension($validator)) |
| 61 | + * ->getFormFactory(); |
70 | 62 | *
|
71 | 63 | * Support for the Templating component is provided by TemplatingExtension.
|
72 | 64 | * This extension needs a PhpEngine object for rendering forms. As second
|
73 | 65 | * argument you should pass the names of the default themes. Here is an
|
74 | 66 | * example for using the default layout with "<div>" tags:
|
75 | 67 | *
|
76 |
| - * <code> |
77 |
| - * use Symfony\Component\Form\Extension\Templating\TemplatingExtension; |
| 68 | + * use Symfony\Component\Form\Extension\Templating\TemplatingExtension; |
78 | 69 | *
|
79 |
| - * $formFactory = Forms::createFormFactoryBuilder() |
80 |
| - * ->addExtension(new TemplatingExtension($engine, null, array( |
81 |
| - * 'FrameworkBundle:Form', |
82 |
| - * ))) |
83 |
| - * ->getFormFactory(); |
84 |
| - * </code> |
| 70 | + * $formFactory = Forms::createFormFactoryBuilder() |
| 71 | + * ->addExtension(new TemplatingExtension($engine, null, array( |
| 72 | + * 'FrameworkBundle:Form', |
| 73 | + * ))) |
| 74 | + * ->getFormFactory(); |
85 | 75 | *
|
86 | 76 | * The next example shows how to include the "<table>" layout:
|
87 | 77 | *
|
88 |
| - * <code> |
89 |
| - * use Symfony\Component\Form\Extension\Templating\TemplatingExtension; |
| 78 | + * use Symfony\Component\Form\Extension\Templating\TemplatingExtension; |
90 | 79 | *
|
91 |
| - * $formFactory = Forms::createFormFactoryBuilder() |
92 |
| - * ->addExtension(new TemplatingExtension($engine, null, array( |
93 |
| - * 'FrameworkBundle:Form', |
94 |
| - * 'FrameworkBundle:FormTable', |
95 |
| - * ))) |
96 |
| - * ->getFormFactory(); |
97 |
| - * </code> |
| 80 | + * $formFactory = Forms::createFormFactoryBuilder() |
| 81 | + * ->addExtension(new TemplatingExtension($engine, null, array( |
| 82 | + * 'FrameworkBundle:Form', |
| 83 | + * 'FrameworkBundle:FormTable', |
| 84 | + * ))) |
| 85 | + * ->getFormFactory(); |
98 | 86 | *
|
99 | 87 | * @author Bernhard Schussek <[email protected]>
|
100 | 88 | */
|
|
0 commit comments