mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-18 16:24:24 +00:00
Add a 'none' text on rendering when the custom fields is empty
close #347
This commit is contained in:
parent
ff40e2991c
commit
b687e9e07d
@ -158,10 +158,18 @@ class CustomFieldChoice implements CustomFieldInterface
|
|||||||
return 'Choices';
|
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)
|
public function render($value, CustomField $customField)
|
||||||
{
|
{
|
||||||
//extract the data. They are under a _choice key if they are stored with allow_other
|
//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);
|
$selected = (is_array($data)) ? $data : array($data);
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
{% if selected|length > 0 %}
|
||||||
<ul class="custom_fields choice">
|
<ul class="custom_fields choice">
|
||||||
{%- for choice in choices -%}
|
{%- for choice in choices -%}
|
||||||
{% if choice['slug'] in selected %}{%- set is_selected = true -%}{%- else -%}{%- set is_selected = false -%}{%- endif -%}
|
{% if choice['slug'] in selected %}{%- set is_selected = true -%}{%- else -%}{%- set is_selected = false -%}{%- endif -%}
|
||||||
@ -16,4 +17,7 @@
|
|||||||
</li>
|
</li>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
</ul>
|
</ul>
|
||||||
|
{% else %}
|
||||||
|
<div class="custom_fields_choice empty">{{ 'None'|trans }}</div>
|
||||||
|
{% endif %}
|
@ -1 +1 @@
|
|||||||
{{ text }}
|
{% if text is not empty %}{{ text }}{% else %}<span class="custom_fields_text empty">{{ 'None'|trans }}</span>{% endif %}
|
Loading…
x
Reference in New Issue
Block a user