@@ -15,9 +15,9 @@ extensions come in.
15
15
Form type extensions have 2 main use cases:
16
16
17
17
#. You want to add a **generic feature to several types ** (such as
18
- adding a "help" text to every field type)
18
+ adding a "help" text to every field type);
19
19
#. You want to add a **specific feature to a single type ** (such
20
- as adding a "download" feature to the "file" field type)
20
+ as adding a "download" feature to the "file" field type).
21
21
22
22
In both those cases, it might be possible to achieve your goal with custom
23
23
form rendering, or custom form field types. But using form type extensions
@@ -56,7 +56,6 @@ That's what you will do in this tutorial::
56
56
57
57
class ImageTypeExtension extends AbstractTypeExtension
58
58
{
59
-
60
59
/**
61
60
* Returns the name of the type being extended.
62
61
*
@@ -154,7 +153,6 @@ database).
154
153
*/
155
154
class Media
156
155
{
157
-
158
156
// ...
159
157
160
158
/**
@@ -186,10 +184,10 @@ database).
186
184
187
185
Your form type extension class will need to do two things:
188
186
189
- 1) Override the ``getDefaultOptions `` method in order to add an image_path
190
- option
191
- 2) Override the ``buildForm `` and ``buildView `` methods in order to pass the image
192
- url to the view
187
+ #. Override the ``getDefaultOptions `` method in order to add an image_path
188
+ option;
189
+ #. Override the ``buildForm `` and ``buildView `` methods in order to pass the image
190
+ url to the view.
193
191
194
192
The logic is the following: when adding a form field of type ``file ``,
195
193
you will be able to specify a new option: ``image_path ``. This option will
@@ -209,7 +207,6 @@ it in the view.
209
207
210
208
class ImageTypeExtension extends AbstractTypeExtension
211
209
{
212
-
213
210
/**
214
211
* Returns the name of the type being extended.
215
212
*
@@ -311,7 +308,6 @@ next to the file field. As an example::
311
308
312
309
class MediaType extends AbstractType
313
310
{
314
-
315
311
public function buildForm(FormBuilder $builder, array $options)
316
312
{
317
313
$builder
0 commit comments