Ejemplo n.º 1
0
 public function render(array $options = [], $showLabel = true, $showField = true, $showError = true)
 {
     dd(parent::getParent());
     $choice = new ChoiceType('some_choice', 'choice', new Form(), $options);
     return $choice->render();
     //return parent::render($options, $showLabel, $showField, $showError);
 }
 public function configureOptions(OptionsResolver $resolver)
 {
     $this->configureFormTypeOptions($resolver);
     parent::configureOptions($resolver);
     $yesNoList = ['Yes', 'No'];
     $resolver->setDefaults(['choices' => array_combine($yesNoList, $yesNoList), 'expanded' => true]);
 }
Ejemplo n.º 3
0
 /**
  * @inheritdoc
  */
 protected function createChildren()
 {
     if ($this->getOption('choices')) {
         return parent::createChildren();
     }
     $entity = $this->getOption('class');
     $queryBuilder = $this->getOption('query_builder');
     $key = $this->getOption('property_key');
     $value = $this->getOption('property');
     if (!$entity || !class_exists($entity)) {
         throw new \InvalidArgumentException(sprintf('Please provide valid "class" option for entity field [%s] in form class [%s]', $this->getRealName(), get_class($this->parent)));
     }
     $entity = new $entity();
     if ($queryBuilder instanceof \Closure) {
         $data = $queryBuilder($entity);
         if (is_object($data) && method_exists($data, 'lists')) {
             $data = $data->lists($value, $key);
         }
     } else {
         $data = $entity->lists($value, $key);
     }
     $this->options['choices'] = $data;
     return parent::createChildren();
 }