♻️ new var_export filter for bolean values

This commit is contained in:
Pierre Goiffon
2020-12-18 17:51:43 +01:00
parent 2608c071d0
commit 8dddf90838
2 changed files with 10 additions and 6 deletions

View File

@@ -136,6 +136,10 @@ class Extension
})
);
// var_export can be used for example to transform a PHP boolean to 'true' or 'false' strings
// @see https://www.php.net/manual/fr/function.var-export.php
$oTwigEnv->addFilter(new Twig_SimpleFilter('var_export', 'var_export'));
// Function to check our current environment
// Usage in twig: {% if is_development_environment() %}

View File

@@ -7,12 +7,12 @@
{# Note: This might not the best way to this, we might rather have some properties for this flags in te Field class. #}
{# For the moment this just aims at restoring the metadata introduced in iTop 2.7. Refactoring the Field class with specialization for each type must be designed by all the team #}
{# as we might want to re-use / adapt the Field classes introduced with the end-user portal #}
data-attribute-flag-hidden="{% if oUIBlock.IsHidden() %}true{% else %}false{% endif %}"
data-attribute-flag-read-only="{% if oUIBlock.IsReadOnly() %}true{% else %}false{% endif %}"
data-attribute-flag-mandatory="{% if oUIBlock.IsMandatory() %}true{% else %}false{% endif %}"
data-attribute-flag-must-change="{% if oUIBlock.IsMustChange() %}true{% else %}false{% endif %}"
data-attribute-flag-must-prompt="{% if oUIBlock.IsMustPrompt() %}true{% else %}false{% endif %}"
data-attribute-flag-slave="{% if oUIBlock.IsSlave() %}true{% else %}false{% endif %}"
data-attribute-flag-hidden="{{ oUIBlock.IsHidden()|var_export }}"
data-attribute-flag-read-only="{{ oUIBlock.IsReadOnly()|var_export }}"
data-attribute-flag-mandatory="{{ oUIBlock.IsMandatory()|var_export }}"
data-attribute-flag-must-change="{{ oUIBlock.IsMustChange()|var_export }}"
data-attribute-flag-must-prompt="{{ oUIBlock.IsMustPrompt()|var_export }}"
data-attribute-flag-slave="{{ oUIBlock.IsSlave()|var_export }}"
data-value-raw="{{ aParams.value_raw }}"
>
<div class="ibo-field--label">{{ oUIBlock.GetLabel()|raw }}</div>