diff --git a/CustomFields/CustomFieldChoice.php b/CustomFields/CustomFieldChoice.php index 907b44817..af030f1da 100644 --- a/CustomFields/CustomFieldChoice.php +++ b/CustomFields/CustomFieldChoice.php @@ -158,10 +158,18 @@ class CustomFieldChoice implements CustomFieldInterface return 'Choices'; } + /** + * + * @internal this function is able to receive data whichever is the value of "other", "multiple" + * @param mixed $value + * @param CustomField $customField + * @return string html representation + */ 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'] : $value; + $data = (isset($value['_choices'])) ? $value['_choices'] : + is_null($value) ? array() : $value; $selected = (is_array($data)) ? $data : array($data); diff --git a/Resources/views/CustomFieldsRendering/choice.html.twig b/Resources/views/CustomFieldsRendering/choice.html.twig index 5bdd18bbd..937897d94 100644 --- a/Resources/views/CustomFieldsRendering/choice.html.twig +++ b/Resources/views/CustomFieldsRendering/choice.html.twig @@ -1,3 +1,4 @@ +{% if selected|length > 0 %} \ No newline at end of file + +{% else %} +
{{ 'None'|trans }}
+{% endif %} \ No newline at end of file diff --git a/Resources/views/CustomFieldsRendering/text.html.twig b/Resources/views/CustomFieldsRendering/text.html.twig index 9b2b76cb3..29db40680 100644 --- a/Resources/views/CustomFieldsRendering/text.html.twig +++ b/Resources/views/CustomFieldsRendering/text.html.twig @@ -1 +1 @@ -{{ text }} \ No newline at end of file +{% if text is not empty %}{{ text }}{% else %}{{ 'None'|trans }}{% endif %} \ No newline at end of file