From 2d5301b25d7db2012f335ac15b7b4f7ffbf5d14a Mon Sep 17 00:00:00 2001 From: Peter Bowyer Date: Mon, 16 May 2016 10:46:22 +0100 Subject: [PATCH 1/2] Show label & set correct value in Symfony 3.X At some point in Symfony history the key/value pairs switched orders, so the friendly label now has to be the key of the array. This change fixes the example. --- cookbook/form/create_custom_field_type.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cookbook/form/create_custom_field_type.rst b/cookbook/form/create_custom_field_type.rst index e6c3ed08ee2..06f75e84bbc 100644 --- a/cookbook/form/create_custom_field_type.rst +++ b/cookbook/form/create_custom_field_type.rst @@ -33,8 +33,8 @@ for form fields, which is ``\Form\Type``. Make sure the field extend { $resolver->setDefaults(array( 'choices' => array( - 'm' => 'Male', - 'f' => 'Female', + 'Male' => 'm', + 'Female' => 'f', ) )); } From 0cbf6bb98bb576731237f40dbdeed64a8bacc2b3 Mon Sep 17 00:00:00 2001 From: Peter Bowyer Date: Mon, 23 May 2016 08:26:26 +0100 Subject: [PATCH 2/2] Add choices_as_values for Symfony 2.7 documentation --- cookbook/form/create_custom_field_type.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cookbook/form/create_custom_field_type.rst b/cookbook/form/create_custom_field_type.rst index 06f75e84bbc..0d3b85411e6 100644 --- a/cookbook/form/create_custom_field_type.rst +++ b/cookbook/form/create_custom_field_type.rst @@ -35,7 +35,8 @@ for form fields, which is ``\Form\Type``. Make sure the field extend 'choices' => array( 'Male' => 'm', 'Female' => 'f', - ) + ), + 'choices_as_values' => true, )); }