From 57fbd54a9c98560b7ac6c23eb60a2a21a2e0c6ee Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Tue, 8 Dec 2015 11:41:34 +0100 Subject: [PATCH 1/3] Removing the choice_with_other_widget that is alreay defined in the main bundle --- Resources/views/Form/fields.html.twig | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/Resources/views/Form/fields.html.twig b/Resources/views/Form/fields.html.twig index 04febae3c..f696dc057 100644 --- a/Resources/views/Form/fields.html.twig +++ b/Resources/views/Form/fields.html.twig @@ -25,11 +25,9 @@ {# CustomFields Choice #} {# render an alement in a choice list #} {% block cf_choices_list_widget %} - -{{ form_row(form.name) }} -{{ form_row(form.active) }} -{{ form_row(form.slug) }} - + {{ form_row(form.name) }} + {{ form_row(form.active) }} + {{ form_row(form.slug) }} {% endblock cf_choices_list_widget %} {# CFChoice : render the different elements in a choice list #} @@ -80,18 +78,6 @@ jQuery(document).ready(initializeCFChoiceOptionsChoices('{{ form.vars.id }}')); +{% endblock cf_choices_row %} -{% endblock cf_choices_row %} - -{% block choice_with_other_widget %} -
-{%- for child in form.children._choices %} -{{- form_widget(child) -}} -{{- form_label(child) -}} -{%- if child.vars.value == '_other' -%} -{{- form_widget(form.children._other) -}} -{%- endif -%} -{% endfor -%} -
- -{% endblock choice_with_other_widget %} \ No newline at end of file +{# The choice_with_other_widget widget is defined in the main bundle #} \ No newline at end of file From ebfb24a3ebaf323cdbfb094a0879fe9ee06f8677 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Tue, 8 Dec 2015 11:42:05 +0100 Subject: [PATCH 2/3] Refactoring CustomFields/CustomFieldChoice.php : removing useless linereturn --- CustomFields/CustomFieldChoice.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/CustomFields/CustomFieldChoice.php b/CustomFields/CustomFieldChoice.php index 304b33ef3..9bad639d6 100644 --- a/CustomFields/CustomFieldChoice.php +++ b/CustomFields/CustomFieldChoice.php @@ -20,14 +20,14 @@ namespace Chill\CustomFieldsBundle\CustomFields; +use Chill\CustomFieldsBundle\Form\Type\ChoicesListType; +use Chill\CustomFieldsBundle\Form\Type\ChoicesType; +use Chill\CustomFieldsBundle\Form\Type\ChoiceWithOtherType; use Chill\CustomFieldsBundle\CustomFields\CustomFieldInterface; use Symfony\Component\Form\FormBuilderInterface; use Chill\CustomFieldsBundle\Entity\CustomField; -use Chill\CustomFieldsBundle\Form\Type\ChoicesType; use Symfony\Component\HttpFoundation\RequestStack; -use Chill\CustomFieldsBundle\Form\Type\ChoicesListType; use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldDataTransformer; -use Chill\CustomFieldsBundle\Form\Type\ChoiceWithOtherType; use Symfony\Bridge\Twig\TwigEngine; use Chill\MainBundle\Templating\TranslatableStringHelper; use Symfony\Component\Translation\Translator; @@ -122,9 +122,7 @@ class CustomFieldChoice implements CustomFieldInterface $builder->create($customField->getSlug(), 'choice', $options) ->addModelTransformer(new CustomFieldDataTransformer($this, $customField)) ); - } - } public function buildOptionsForm(FormBuilderInterface $builder) From 373edab629595e6f5edcf4f2bf111fe1be2174d8 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Tue, 8 Dec 2015 11:42:38 +0100 Subject: [PATCH 3/3] CustomFields/CustomFieldInterface.php : Improving the doc --- CustomFields/CustomFieldInterface.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CustomFields/CustomFieldInterface.php b/CustomFields/CustomFieldInterface.php index 149e5500b..994172e41 100644 --- a/CustomFields/CustomFieldInterface.php +++ b/CustomFields/CustomFieldInterface.php @@ -13,7 +13,9 @@ interface CustomFieldInterface { /** - * + * Return a form type to edit the custom field. This form is shown to the + * user. + * * @param \Chill\CustomFieldsBundle\CustomField\FormBuilderInterface $builder * @param \Chill\CustomFieldsBundle\CustomField\CustomField $customField * @return \Symfony\Component\Form\FormTypeInterface the form type @@ -21,7 +23,7 @@ interface CustomFieldInterface public function buildForm(FormBuilderInterface $builder, CustomField $customField); /** - * transform the value into a format that can be stored in DB + * Transform the value into a format that can be stored in DB * * @param mixed $value * @param \Chill\CustomFieldsBundle\CustomField\CustomField $customField @@ -38,6 +40,7 @@ interface CustomFieldInterface public function deserialize($serialized, CustomField $customField); /** + * Return a repsentation of the value of the CustomField. * * @param mixed $value the raw value, **not deserialized** (= as stored in the db) * @param \Chill\CustomFieldsBundle\CustomField\CustomField $customField @@ -48,7 +51,7 @@ interface CustomFieldInterface public function getName(); /** - * return a formType which allow to edit option for the custom type. + * Return a formType which allow to edit option for the custom type. * This FormType is shown in admin * * @param \Chill\CustomFieldsBundle\CustomField\FormBuilderInterface $builder