diff --git a/CustomFields/CustomFieldLongChoice.php b/CustomFields/CustomFieldLongChoice.php index 58285d132..0b9100935 100644 --- a/CustomFields/CustomFieldLongChoice.php +++ b/CustomFields/CustomFieldLongChoice.php @@ -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, ' diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index bf29b6e7b..f71cbf98a 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -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