From ac08120d4985b9647e319f5b10b1cb2cb248391e Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 17 Jun 2019 17:51:36 +0200 Subject: [PATCH] [Forms] Reworded the article about creating custom form types --- ...tom-type-postal-address-fragment-names.svg | 1 + .../form/form-custom-type-postal-address.svg | 1 + ...tom-type-postal-address-fragment-names.dia | Bin 0 -> 2578 bytes .../form/form-custom-type-postal-address.dia | Bin 0 -> 2075 bytes form/create_custom_field_type.rst | 599 +++++++++++------- form/create_form_type_extension.rst | 5 +- form/data_transformers.rst | 15 +- form/dynamic_form_modification.rst | 9 +- form/form_dependencies.rst | 150 +---- form/use_empty_data.rst | 6 +- 10 files changed, 417 insertions(+), 369 deletions(-) create mode 100644 _images/form/form-custom-type-postal-address-fragment-names.svg create mode 100644 _images/form/form-custom-type-postal-address.svg create mode 100644 _images/sources/form/form-custom-type-postal-address-fragment-names.dia create mode 100644 _images/sources/form/form-custom-type-postal-address.dia diff --git a/_images/form/form-custom-type-postal-address-fragment-names.svg b/_images/form/form-custom-type-postal-address-fragment-names.svg new file mode 100644 index 00000000000..9b6092c9808 --- /dev/null +++ b/_images/form/form-custom-type-postal-address-fragment-names.svg @@ -0,0 +1 @@ + diff --git a/_images/form/form-custom-type-postal-address.svg b/_images/form/form-custom-type-postal-address.svg new file mode 100644 index 00000000000..ab0fde8af3a --- /dev/null +++ b/_images/form/form-custom-type-postal-address.svg @@ -0,0 +1 @@ + diff --git a/_images/sources/form/form-custom-type-postal-address-fragment-names.dia b/_images/sources/form/form-custom-type-postal-address-fragment-names.dia new file mode 100644 index 0000000000000000000000000000000000000000..aebdadb41701a5dbfc9f99f809b3ed9135447dc8 GIT binary patch literal 2578 zcmV+t3hnhDiwFP!000021MOW~Z{kQ6e(zsl(XULU?w4VbQBO-Ft+d){se51M1sQON zXN--E=`{N=zkRE0hY*4Zi7#AoKyKIFeGk$_n8epTf^g3Z z;&CzwnkLJ5(koh( z?Z!!zq~3Qwy6%0v&0oE%vYV?X{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ha;gU4uzhmagl0(gFo480?H{A{tc0oThG4a|Btj*nlw zyx8P$JDR(QeM@7lQ%4nBCi>1-@E34~(PQ7qP*ph3`?A%zlU3vP*tTUWn=_uvHi|#| zQ18eYc^mXj1b~pDJ|aL6NRLkMga9gXI12e7LuVBCQC1EYq)Ff$hPOKO@{t`p;vJ2N ziDwYc8)M$!294E^rpMVmZ-#wa@c5p^CR*tKHqhbtxnz>I0aPPtr5$cq60M5t6fk4# z-HGhkios02GofMRo>| zXoCM@k-h1FYl`g9it1KWx1zcg)vc($DXN>O3$Oob04q~iC|nW|2JL^8*x=yj>;AEze9%dDyIBr^licV?k)PKGl-$QZZp+yzk-TUq^-vU-(q zTfVYc;<>+P-pY&S*aQo1;j_Cbn=bH3Q8rz{e{E$`%iO19?rN*GuP45u*Ar{79BNez zV}N(MIfMd{v)mG2T9&gc_rh%-+g58??y^`8w^g~#^%n`abVV1j92FU!0Gx`Va+~2} z7r5MgRh8S%emb`W+tU_oD@@lGY;7uj<^@|wS`AVKAdqxeu@wL_!UhBv6Q zwoM0IuVM>bTd}njTU)WU8K$k+ZdPn15D?jl?P)8vv?W2maH_H+sS7?iaZw8T3w$ee zS*feOpkHORR_eMesf)EKbr}bSDZw?TvrB5V+0 zg9sZ$q#GW~4qp^}i~swYwcIYPSP|ZLu6-`JYji4AV|nuEcW* zrh}(*0T670Z&~gaW4Q{ewJdk0ELU8~;>Brpp*RiHT*o(WiWBoSj@9Jm&Hqw%7h`jc F002)30rmg@ literal 0 HcmV?d00001 diff --git a/form/create_custom_field_type.rst b/form/create_custom_field_type.rst index ec8c1773afb..e17c10013de 100644 --- a/form/create_custom_field_type.rst +++ b/form/create_custom_field_type.rst @@ -4,23 +4,30 @@ How to Create a Custom Form Field Type ====================================== -Symfony comes with a bunch of core field types available for building forms. -However there are situations where you may want to create a custom form field -type for a specific purpose. This article assumes you need a field definition -that holds a shipping option, based on the existing choice field. This section -explains how the field is defined and how you can customize its layout. - -Defining the Field Type ------------------------ - -In order to create the custom field type, first you have to create the class -representing the field. In this situation the class holding the field type -will be called ``ShippingType`` and the file will be stored in the default location -for form fields, which is ``App\Form\Type``. - -All field types must implement the :class:`Symfony\\Component\\Form\\FormTypeInterface`, +Symfony comes with :doc:`tens of form types ` (called +"form fields" in other projects) ready to use in your applications. However, +it's common to create custom form types to solve specific purposes in your +projects. + +Creating Form Types Based on Symfony Built-in Types +--------------------------------------------------- + +The easiest way to create a form type is to base it on one of the +:doc:`existing form types `. Imagine that your project +displays a list of "shipping options" as a ``