From 043f5a1eafeba8c7144230eb46a8a4310628dd7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 5 Nov 2015 23:49:22 +0100 Subject: [PATCH] fix show page --- Controller/CustomFieldsGroupController.php | 28 +++++- Resources/translations/messages.fr.yml | 13 ++- .../views/CustomFieldsGroup/show.html.twig | 92 ++++++++++++++----- 3 files changed, 107 insertions(+), 26 deletions(-) diff --git a/Controller/CustomFieldsGroupController.php b/Controller/CustomFieldsGroupController.php index 0be440be4..a5c67e95f 100644 --- a/Controller/CustomFieldsGroupController.php +++ b/Controller/CustomFieldsGroupController.php @@ -6,6 +6,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Doctrine\ORM\Query; use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup; +use Chill\CustomFieldsBundle\Entity\CustomField; /** * CustomFieldsGroup controller. @@ -152,11 +153,9 @@ class CustomFieldsGroupController extends Controller throw $this->createNotFoundException('Unable to find CustomFieldsGroup entity.'); } - $deleteForm = $this->createDeleteForm($id); - return $this->render('ChillCustomFieldsBundle:CustomFieldsGroup:show.html.twig', array( 'entity' => $entity, - 'delete_form' => $deleteForm->createView(), + 'create_field_form' => $this->createCreateFieldForm($entity)->createView() )); } @@ -201,6 +200,29 @@ class CustomFieldsGroupController extends Controller return $form; } + + private function createCreateFieldForm(CustomFieldsGroup $customFieldsGroup) + { + + $fieldChoices = array(); + foreach ($this->get('chill.custom_field.provider')->getAllFields() + as $key => $customType) { + $fieldChoices[$key] = $customType->getName(); + } + + return $this->createFormBuilder(new CustomField(), array( + 'method' => 'GET', + 'action' => $this->generateUrl('customfield_new', + array('cfGroup' => $customFieldsGroup->getId())), + 'csrf_protection' => false + )) + ->add('type', 'choice', array( + 'choices' => $fieldChoices + )) + ->add('submit', 'submit') + ->getForm(); + } + /** * Edits an existing CustomFieldsGroup entity. * diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 2a7873d98..463bc0dd3 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -2,7 +2,7 @@ 'Other value': 'Autre valeur' 'None': 'Pas spécifié' -Custom fields configuration: Configuration des champs personnalisés + CustomFieldsGroup list: Groupes de champs personnalisés CustomFieldsGroup creation: Nouveau groupe de champs personnalisés Entity: Entité @@ -10,6 +10,17 @@ Entity: Entité "Some module select default groups for some usage. Example: the default person group is shown under person page.": "Certains modules sélectionnent en priorité les formulaires par défaut. Exemple: le formulaire par défaut pour une personne est affiché sur la page principale pour la personne" Make default: Assigner comme formulaire par défaut Create a new group: Créer un nouveau groupe +CustomFieldsGroup details: Détail du groupe de champs personnalisés +Fields associated with this group: Champs associés à ce groupe +Any field is currently associated with this group: Aucun champ n'est associé à ce groupe actuellement +Create a new field: Créer un champ personnalisé +Add a new field: Ajouter un champ personnalisé +ordering: ordre +label_field: label du champ +active: actif + +#menu entries +Custom fields configuration: Champs personnalisés CustomFields List: Liste des champs personnalisés CustomFields Groups: Groupe de champs personnalisés diff --git a/Resources/views/CustomFieldsGroup/show.html.twig b/Resources/views/CustomFieldsGroup/show.html.twig index 84a0141d2..bdbe2bad5 100644 --- a/Resources/views/CustomFieldsGroup/show.html.twig +++ b/Resources/views/CustomFieldsGroup/show.html.twig @@ -16,37 +16,85 @@ #} {% extends "ChillCustomFieldsBundle::Admin/layout.html.twig" %} +{% block title%}{{ 'CustomFieldsGroup details'|trans }}{% endblock %} + {% block admin_content %} -

CustomFieldsGroup

+

{{ 'CustomFieldsGroup details'|trans }}

- - + + - - - - - - + +
Id{{ entity.id }}{{ 'Name'|trans }}{{ entity.getName|localize_translatable_string }}
Name{{ entity.getName(app.request.locale) }}
Entity{{ entity.entity }}{{ 'Entity'|trans }}{{ entity.entity|trans }}
- + + +

{{ 'Fields associated with this group'|trans }}

+ + {%- if entity.customFields|length > 0 -%} + + + + + + + + + + + + {%- for field in entity.customFields -%} + + + + + + + + {%- endfor -%} + +
{{ 'ordering'|trans|capitalize }}{{ 'label_field'|trans|capitalize }}{{ 'type'|trans|capitalize }}{{ 'active'|trans|capitalize }} 
{{ field.ordering }}{{ field.name|localize_translatable_string }}{{ field.type|trans }} + {%- if field.active -%} + + {%- else -%} + + {%- endif -%} + + {{ 'edit'|trans|capitalize }} +
+ {{ form_start(create_field_form) }} +
+ {{ form_widget(create_field_form.type) }} +
+ {{ form_widget(create_field_form.submit, { 'attr': { 'class': 'sc-button bt-create' }, 'label': 'Add a new field' } ) }} + {{ form_end(create_field_form) }} + {%- else -%} +

+ {{ 'Any field is currently associated with this group'|trans }} +

+ {{ form_start(create_field_form) }} +
+ {{ form_widget(create_field_form.type) }} +
+ {{ form_widget(create_field_form.submit, { 'attr': { 'class': 'sc-button bt-create' }, 'label': 'Create a new field' } ) }} + {{ form_end(create_field_form) }} + {%- endif -%} {% endblock %}