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 00000000000..aebdadb4170 Binary files /dev/null and b/_images/sources/form/form-custom-type-postal-address-fragment-names.dia differ diff --git a/_images/sources/form/form-custom-type-postal-address.dia b/_images/sources/form/form-custom-type-postal-address.dia new file mode 100644 index 00000000000..35a1eaebfd6 Binary files /dev/null and b/_images/sources/form/form-custom-type-postal-address.dia differ 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 ``