From a925533fc806efc9f8da4af86d770d1590629cf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 27 Nov 2014 13:54:58 +0100 Subject: [PATCH] fix bug : CFChoice was not rendered correctly with _other option --- CustomFields/CustomFieldChoice.php | 7 ++----- .../views/CustomFieldsRendering/choice.html.twig | 14 +++++++------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/CustomFields/CustomFieldChoice.php b/CustomFields/CustomFieldChoice.php index ca4af6a9e..61508b36e 100644 --- a/CustomFields/CustomFieldChoice.php +++ b/CustomFields/CustomFieldChoice.php @@ -185,11 +185,8 @@ class CustomFieldChoice implements CustomFieldInterface public function render($value, CustomField $customField) { //extract the data. They are under a _choice key if they are stored with allow_other - $data = (isset($value['_choices'])) ? $value['_choices'] : - is_null($value) ? array() : $value; - - $selected = (is_array($data)) ? $data : array($data); - + $data = (isset($value['_choices'])) ? $value['_choices'] : $value; + $selected = (is_array($data)) ? $data : array($data); $choices = $customField->getOptions()[self::CHOICES]; if (in_array('_other', $selected)){ diff --git a/Resources/views/CustomFieldsRendering/choice.html.twig b/Resources/views/CustomFieldsRendering/choice.html.twig index 937897d94..f5bd582d2 100644 --- a/Resources/views/CustomFieldsRendering/choice.html.twig +++ b/Resources/views/CustomFieldsRendering/choice.html.twig @@ -5,15 +5,15 @@ {%- if is_selected -%}
  • {%- if is_selected -%} - +   {%- else -%} - +   + {%- endif -%} + {%- if choice['slug'] is not same as('_other') -%} + {{ choice['name'][app.request.locale]|default(choice['name'][locale]|default('Not available in your language'|trans)) }} + {%- else -%} + {{ choice['name'] }} {%- endif -%} - {%- if choice['slug'] is not same as('_other') -%} - {{ choice['name'][app.request.locale]|default(choice['name'][locale]|default('Not available in your language'|trans)) }} - {%- else -%} - {{ 'Other value'|trans }} : {{ choice['name'] }} - {%- endif -%}
  • {%- endif -%} {%- endfor -%}