show options in show view

This commit is contained in:
Julien Fastré 2015-11-08 18:47:16 +01:00
parent 0dcf2c33f0
commit 3e23c1f156
3 changed files with 43 additions and 2 deletions

View File

@ -154,12 +154,36 @@ class CustomFieldsGroupController extends Controller
if (!$entity) {
throw $this->createNotFoundException('Unable to find CustomFieldsGroup entity.');
}
$options = $this->getOptionsAvailable($entity->getEntity());
return $this->render('ChillCustomFieldsBundle:CustomFieldsGroup:show.html.twig', array(
'entity' => $entity,
'create_field_form' => $this->createCreateFieldForm($entity)->createView()
'create_field_form' => $this->createCreateFieldForm($entity)->createView(),
'options' => $options
));
}
/**
* Return an array of available key option for custom fields group
* on the given entity
*
* @param string $entity the entity to filter
*/
private function getOptionsAvailable($entity)
{
$options = $this->getParameter('chill_custom_fields.'
. 'customizables_entities');
foreach($options as $key => $definition) {
if ($definition['class'] == $entity) {
foreach ($definition['options'] as $key => $value) {
yield $key;
}
}
}
// [$entity->getEntity()];
}
/**
* Displays a form to edit an existing CustomFieldsGroup entity.

View File

@ -18,6 +18,7 @@ Add a new field: Ajouter un champ personnalisé
ordering: ordre
label_field: label du champ
active: actif
No value defined for this option: Pas de valeur pour cette option
CustomFieldsGroup edit: Edition d'un groupe de champs personnalisé

View File

@ -16,7 +16,7 @@
#}
{% extends "ChillCustomFieldsBundle::Admin/layout.html.twig" %}
{% block title%}{{ 'CustomFieldsGroup details'|trans }}{% endblock %}
{% block title %}{{ 'CustomFieldsGroup details'|trans }}{% endblock %}
{% block admin_content %}
<h1>{{ 'CustomFieldsGroup details'|trans }}</h1>
@ -31,6 +31,22 @@
<th>{{ 'Entity'|trans }}</th>
<td>{{ entity.entity|trans }}</td>
</tr>
{%- for key in options -%}
<tr>
<th>{{ key ~ '_label'|trans }}</th>
<td>
{%- if entity.options[key] is not defined -%}
{{ 'No value defined for this option'|trans }}
{%- elseif entity.options[key] is iterable -%}
{{ entity.options[key]|join(', ') }}
{% else %}
{{ entity.options[key] }}
{%- endif -%}
</td>
</tr>
{%- else -%}
<!-- no option available for this entity -->
{%- endfor -%}
</tbody>
</table>