mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-19 08:44:24 +00:00
allow choosing empty value in CFLongChoice
This commit is contained in:
parent
9c622bc852
commit
cbc66dc0f0
@ -19,7 +19,6 @@
|
||||
|
||||
namespace Chill\CustomFieldsBundle\CustomFields;
|
||||
|
||||
use Chill\CustomFieldsBundle\CustomFields\CustomFieldInterface;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Chill\CustomFieldsBundle\Entity\CustomField;
|
||||
use Chill\CustomFieldsBundle\EntityRepository\CustomFieldLongChoice\OptionRepository;
|
||||
@ -84,6 +83,8 @@ class CustomFieldLongChoice extends AbstractCustomField
|
||||
'choices_as_values' => true,
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
'required' => $customField->isRequired(),
|
||||
'placeholder' => 'Choose a value',
|
||||
'group_by' => function(Option $option) use ($translatableStringHelper) {
|
||||
if ($option->hasParent()) {
|
||||
return $translatableStringHelper->localize($option->getParent()->getText());
|
||||
@ -137,12 +138,16 @@ class CustomFieldLongChoice extends AbstractCustomField
|
||||
|
||||
return $this->templating
|
||||
->render($template, array(
|
||||
'values' => array($option)
|
||||
'values' => $option === NULL ? array() : array($option)
|
||||
));
|
||||
}
|
||||
|
||||
public function serialize($value, \Chill\CustomFieldsBundle\Entity\CustomField $customField)
|
||||
{
|
||||
if ($value === NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!$value instanceof Option) {
|
||||
throw new \LogicException('the value should be an instance of '
|
||||
. 'Chill\CustomFieldsBundle\Entity\CustomFieldLongChoice\Option, '
|
||||
|
@ -91,3 +91,4 @@ Text after the field: Texte après le champ
|
||||
|
||||
#custom field long choice
|
||||
Options key: Clé des options
|
||||
Choose a value: Choisissez une valeur
|
||||
|
Loading…
x
Reference in New Issue
Block a user