Improve rendering of options and fields

This commit is contained in:
Julien Fastré 2015-11-27 13:37:07 +01:00
parent f24a088a0d
commit bf99b68a2a
6 changed files with 65 additions and 16 deletions

View File

@ -122,7 +122,13 @@ class CustomFieldText implements CustomFieldInterface
return $builder
->add(self::MAX_LENGTH, 'integer', array('empty_data' => 256))
->add(self::MULTIPLE_CF_INLINE, 'choice', array(
'choices' => array('1' => 'True', '0' => 'False')))
'choices' => array(
'1' => 'Multiple boxes on the line',
'0' => 'One box on the line'
),
'label' => 'Box appearance',
'expanded' => True
))
;
}
}

View File

@ -96,10 +96,13 @@ class CustomFieldTitle implements CustomFieldInterface
public function buildOptionsForm(FormBuilderInterface $builder)
{
return $builder->add(self::TYPE, 'choice',
array('choices' => array(
self::TYPE_TITLE => self::TYPE_TITLE,
self::TYPE_SUBTITLE => self::TYPE_SUBTITLE
))
array(
'choices' => array(
self::TYPE_TITLE => 'Main title',
self::TYPE_SUBTITLE => 'Subtitle'
),
'label' => 'Title level'
)
);
}
}

View File

@ -20,6 +20,7 @@ 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é
type: type
#menu entries
@ -29,11 +30,19 @@ CustomFields Groups: Groupe de champs personnalisés
#customfield administration
CustomField edit: Modification d'un champ personnalisé
CustomField creation: Nouveau champ personnalisé
General informations: Informations générales
Options: Options
Custom fields group: Groupe de champ personnalisé
Ordering: Ordre d'apparition
Back to the group: Retour au groupe de champs personnalisé
Slug: Identifiant textuel
#custom field name
choice: choix
title: titre
text: texte
text field: champ texte
#custom field choice
Multiplicity: Multiplicité
@ -47,3 +56,15 @@ No: Non
Yes: Oui
Other value label (empty if use by default): Label du champ "autre valeur"
Choices: Choix
Add an element: Ajouter un élément
#custom field text
Max length: Longueur maximum
Box appearance: Apparence du champ
Multiple boxes on the line: Plusieurs champs sur la ligne
One box on the line: Un seul champ sur la ligne
#custom field title
Title level: Niveau de titre
Main title: Titre principal
Subtitle: Sous-titre

View File

@ -40,7 +40,7 @@
<ul class="record_actions">
<li>
<a href="{{ path('customfieldsgroup_show', { 'id': entity.customFieldsGroup.id }) }}">
<a href="{{ path('customfieldsgroup_show', { 'id': entity.customFieldsGroup.id }) }}" class="sc-button btn-reset">
{{ 'Back to the group'|trans }}
</a>
</li>

View File

@ -16,14 +16,33 @@
#}
{% extends "ChillCustomFieldsBundle::Admin/layout.html.twig" %}
{% block admin_content %}
<h1>CustomField creation</h1>
{% block title %}{{ 'CustomField creation'|trans }}{% endblock title %}
{{ form(form) }}
<ul class="record_actions">
{% block admin_content %}
<h1>{{ 'CustomField creation'|trans }}</h1>
<h2>{{ 'General informations'|trans }}</h2>
{{ form_start(form) }}
{{ form_row(form.name) }}
{{ form_row(form.active) }}
{{ form_row(form.slug) }}
{% if form.customFieldsGroup is defined %}
{{ form_row(form.customFieldsGroup) }}
{% endif %}
{{ form_row(form.ordering) }}
{% if form.options is not empty %}
<h2>{{ 'Options'|trans }}</h2>
{% for option in form.options %}
{{ form_row(option) }}
{% endfor %}
{% endif %}
{{ form_row(form.submit, {'attr': { 'class': 'sc-button btn-create' } } ) }}
{{ form_end(form) }}
<ul class="record_actions">
<li>
<a href="{{ path('customfield') }}">
Back to the list
<a href="{{ path('customfieldsgroup_show', { 'id': entity.customFieldsGroup.id }) }}" class="sc-button btn-reset">
{{ 'Back to the group'|trans }}
</a>
</li>
</ul>

View File

@ -35,17 +35,17 @@
{# CFChoice : render the different elements in a choice list #}
{% block cf_choices_row %}
<h3>{{ 'Choices'|trans }}</h3>
{{ dump(form.vars.prototype.children) }}
<div id="{{ form.vars.id }}" data-prototype="{{- form_row(form.vars.prototype.children.name)
~ form_row(form.vars.prototype.children.active)
~ form_row(form.vars.prototype.children.slug) |e -}}">
~ form_row(form.vars.prototype.children.slug) -}}">
<table><tbody>
{% for choice in form %}
<tr><td>
{{ form_row(choice.name) }}
{{ form_row(choice.active) }}
{{ form_row(choice.slug) }}
</td></tr>
</td></tr>
{% endfor %}
</tbody></table>
</div>
@ -67,7 +67,7 @@
}
function initializeCFChoiceOptionsChoices(div_id) {
var add_element_link = $('<a id="' + div_id + '_add_element_link"" href="#" class="sc-button bt-submit">Add an element</a>');
var add_element_link = $('<a id="' + div_id + '_add_element_link"" href="#" class="sc-button bt-submit">{{ 'Add an element'|trans }}</a>');
var div = $('#' + div_id);
div.append(add_element_link);
div.data('index', div.find(':input').length / 5);