コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $choices = $this->option->getValues();
     if (!$choices->first()) {
         throw new MissingOptionsException(sprintf('The option "%s" must have values assigned before it may be used in a form.', $this->option->getName()));
     }
     $class = get_class($choices->first());
     // Remove locked values from choice list.
     $choices = $choices->filter(function ($choice) {
         return !$choice->isLocked();
     });
     // Sort choice list.
     $choices = OptionOrder::sort($choices, $this->sortBy);
     $resolver->setDefaults(array('class' => $class, 'choices' => $choices, 'empty_value' => 'dag.option.form.choose'));
 }