mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-15 06:44:24 +00:00
Merge branch 'marcu/Chill-CustomFields-master'
Merge request Chill-project/Chill-CustomFields!5 Conflicts: Resources/views/Form/fields.html.twig
This commit is contained in:
commit
b88bb50b56
@ -20,14 +20,14 @@
|
|||||||
|
|
||||||
namespace Chill\CustomFieldsBundle\CustomFields;
|
namespace Chill\CustomFieldsBundle\CustomFields;
|
||||||
|
|
||||||
|
use Chill\CustomFieldsBundle\Form\Type\ChoicesListType;
|
||||||
|
use Chill\CustomFieldsBundle\Form\Type\ChoicesType;
|
||||||
|
use Chill\CustomFieldsBundle\Form\Type\ChoiceWithOtherType;
|
||||||
use Chill\CustomFieldsBundle\CustomFields\CustomFieldInterface;
|
use Chill\CustomFieldsBundle\CustomFields\CustomFieldInterface;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Chill\CustomFieldsBundle\Entity\CustomField;
|
use Chill\CustomFieldsBundle\Entity\CustomField;
|
||||||
use Chill\CustomFieldsBundle\Form\Type\ChoicesType;
|
|
||||||
use Symfony\Component\HttpFoundation\RequestStack;
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
use Chill\CustomFieldsBundle\Form\Type\ChoicesListType;
|
|
||||||
use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldDataTransformer;
|
use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldDataTransformer;
|
||||||
use Chill\CustomFieldsBundle\Form\Type\ChoiceWithOtherType;
|
|
||||||
use Symfony\Bridge\Twig\TwigEngine;
|
use Symfony\Bridge\Twig\TwigEngine;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Symfony\Component\Translation\Translator;
|
use Symfony\Component\Translation\Translator;
|
||||||
@ -122,9 +122,7 @@ class CustomFieldChoice implements CustomFieldInterface
|
|||||||
$builder->create($customField->getSlug(), 'choice', $options)
|
$builder->create($customField->getSlug(), 'choice', $options)
|
||||||
->addModelTransformer(new CustomFieldDataTransformer($this, $customField))
|
->addModelTransformer(new CustomFieldDataTransformer($this, $customField))
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildOptionsForm(FormBuilderInterface $builder)
|
public function buildOptionsForm(FormBuilderInterface $builder)
|
||||||
|
@ -13,6 +13,8 @@ interface CustomFieldInterface
|
|||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Return a form type to edit the custom field. This form is shown to the
|
||||||
|
* user.
|
||||||
*
|
*
|
||||||
* @param \Chill\CustomFieldsBundle\CustomField\FormBuilderInterface $builder
|
* @param \Chill\CustomFieldsBundle\CustomField\FormBuilderInterface $builder
|
||||||
* @param \Chill\CustomFieldsBundle\CustomField\CustomField $customField
|
* @param \Chill\CustomFieldsBundle\CustomField\CustomField $customField
|
||||||
@ -21,7 +23,7 @@ interface CustomFieldInterface
|
|||||||
public function buildForm(FormBuilderInterface $builder, CustomField $customField);
|
public function buildForm(FormBuilderInterface $builder, CustomField $customField);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* transform the value into a format that can be stored in DB
|
* Transform the value into a format that can be stored in DB
|
||||||
*
|
*
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @param \Chill\CustomFieldsBundle\CustomField\CustomField $customField
|
* @param \Chill\CustomFieldsBundle\CustomField\CustomField $customField
|
||||||
@ -38,6 +40,7 @@ interface CustomFieldInterface
|
|||||||
public function deserialize($serialized, CustomField $customField);
|
public function deserialize($serialized, CustomField $customField);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Return a repsentation of the value of the CustomField.
|
||||||
*
|
*
|
||||||
* @param mixed $value the raw value, **not deserialized** (= as stored in the db)
|
* @param mixed $value the raw value, **not deserialized** (= as stored in the db)
|
||||||
* @param \Chill\CustomFieldsBundle\CustomField\CustomField $customField
|
* @param \Chill\CustomFieldsBundle\CustomField\CustomField $customField
|
||||||
@ -48,7 +51,7 @@ interface CustomFieldInterface
|
|||||||
public function getName();
|
public function getName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return a formType which allow to edit option for the custom type.
|
* Return a formType which allow to edit option for the custom type.
|
||||||
* This FormType is shown in admin
|
* This FormType is shown in admin
|
||||||
*
|
*
|
||||||
* @param \Chill\CustomFieldsBundle\CustomField\FormBuilderInterface $builder
|
* @param \Chill\CustomFieldsBundle\CustomField\FormBuilderInterface $builder
|
||||||
|
@ -25,11 +25,9 @@
|
|||||||
{# CustomFields Choice #}
|
{# CustomFields Choice #}
|
||||||
{# render an alement in a choice list #}
|
{# render an alement in a choice list #}
|
||||||
{% block cf_choices_list_widget %}
|
{% block cf_choices_list_widget %}
|
||||||
|
|
||||||
{{ form_row(form.name) }}
|
{{ form_row(form.name) }}
|
||||||
{{ form_row(form.active) }}
|
{{ form_row(form.active) }}
|
||||||
{{ form_row(form.slug) }}
|
{{ form_row(form.slug) }}
|
||||||
|
|
||||||
{% endblock cf_choices_list_widget %}
|
{% endblock cf_choices_list_widget %}
|
||||||
|
|
||||||
{# CFChoice : render the different elements in a choice list #}
|
{# CFChoice : render the different elements in a choice list #}
|
||||||
@ -80,42 +78,7 @@
|
|||||||
|
|
||||||
jQuery(document).ready(initializeCFChoiceOptionsChoices('{{ form.vars.id }}'));
|
jQuery(document).ready(initializeCFChoiceOptionsChoices('{{ form.vars.id }}'));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{% endblock cf_choices_row %}
|
{% endblock cf_choices_row %}
|
||||||
|
|
||||||
{% block choice_with_other_widget %}
|
{# The choice_with_other_widget widget is defined in the main bundle #}
|
||||||
<div {{ block('widget_container_attributes') }}>
|
|
||||||
{%- for child in form.children._choices %}
|
|
||||||
{{- form_widget(child) -}}
|
|
||||||
{{- form_label(child) -}}
|
|
||||||
{%- if child.vars.value == '_other' -%}
|
|
||||||
{{- form_widget(form.children._other) -}}
|
|
||||||
{%- endif -%}
|
|
||||||
{% endfor -%}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% endblock choice_with_other_widget %}
|
|
||||||
|
|
||||||
{# extend the integer type to add post_text extension #}
|
|
||||||
{% block integer_widget %}
|
|
||||||
{%- if post_text is defined and post_text is not empty-%}
|
|
||||||
<div class="input_with_post_text">
|
|
||||||
{%- endif -%}
|
|
||||||
{{ block('form_widget') }}
|
|
||||||
{%- if post_text is defined and post_text is not empty-%}
|
|
||||||
<span class="cf_post_text">{{ post_text }}</span>
|
|
||||||
</div>
|
|
||||||
{%- endif -%}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{# extend the number type to add post_text extension #}
|
|
||||||
{% block number_widget %}
|
|
||||||
{%- if post_text is defined and post_text is not empty-%}
|
|
||||||
<div class="input_with_post_text">
|
|
||||||
{%- endif -%}
|
|
||||||
{{ block('form_widget') }}
|
|
||||||
{%- if post_text is defined and post_text is not empty-%}
|
|
||||||
<span class="cf_post_text">{{ post_text }}</span>
|
|
||||||
</div>
|
|
||||||
{%- endif -%}
|
|
||||||
{% endblock %}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user