/** * {@inheritDoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { if ($options['multiple']) { $builder->addEventSubscriber(new MergeCollectionListener($options['model_manager']))->prependClientTransformer(new ModelsToArrayTransformer($options['choice_list'])); } else { $builder->prependClientTransformer(new ModelToIdTransformer($options['model_manager'], $options['class'])); } }
public function buildForm(FormBuilderInterface $builder, array $options) { $builder->prependClientTransformer(new CategoriesCollectionTransformer($options['entityCategoryClass']))->addEventSubscriber(new CategoriesMergeCollectionListener()); $registries = \CategoryRegistryUtil::getRegisteredModuleCategories($options['module'], $options['entity'], 'id'); foreach ($registries as $registryId => $categoryId) { $builder->add('registry_' . $registryId, 'entity', array('class' => 'ZikulaCategoriesModule:CategoryEntity', 'property' => 'name', 'query_builder' => function (EntityRepository $repo) use($categoryId) { //TODO: (move to)/use own entity repository after CategoryUtil migration return $repo->createQueryBuilder('e')->where('e.parent = :parentId')->setParameter('parentId', (int) $categoryId); })); } }
public function buildForm(FormBuilderInterface $builder, array $options) { $entities = $this->container->getParameter('shtumi.dependent_filtered_entities'); $options['class'] = $entities[$options['entity_alias']]['class']; $options['property'] = $entities[$options['entity_alias']]['property']; $options['no_result_msg'] = $entities[$options['entity_alias']]['no_result_msg']; $builder->prependClientTransformer(new EntityToIdTransformer($this->container->get('doctrine')->getEntityManager(), $options['class'])); $builder->setAttribute("parent_field", $options['parent_field']); $builder->setAttribute("entity_alias", $options['entity_alias']); $builder->setAttribute("no_result_msg", $options['no_result_msg']); $builder->setAttribute("empty_value", $options['empty_value']); }
public function buildForm(FormBuilderInterface $builder, array $options) { $entities = $this->container->getParameter('shtumi.autocomplete_entities'); if (null === $options['entity_alias']) { throw new FormException('You must provide a entity alias "entity_alias" and tune it in config file'); } if (!isset($entities[$options['entity_alias']])) { throw new FormException('There are no entity alias "' . $options['entity_alias'] . '" in your config file'); } $options['class'] = $entities[$options['entity_alias']]['class']; $options['property'] = $entities[$options['entity_alias']]['property']; $builder->prependClientTransformer(new EntityToPropertyTransformer($this->container->get('doctrine')->getEntityManager(), $options['class'], $options['property'])); $builder->setAttribute('entity_alias', $options['entity_alias']); }
/** * {@inheritDoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder->prependClientTransformer(new ModelToIdTransformer($options['model_manager'], $options['class'])); }
/** * Builds the form. * * @param FormBuilderInterface $builder The form builder * @param array $options The options * * @return void */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder->prependClientTransformer(new EntitiesToStringTransformer($this->registry->getEntityManager())); }
public function buildForm(FormBuilderInterface $builder, array $options) { if ($options['multiple']) { $builder->prependClientTransformer(new CollectionToArrayTransformer()); } }
/** * {@inheritdoc} */ public function buildForm(Form\FormBuilderInterface $builder, array $options) { $builder->prependClientTransformer($this->dataTransformer)->add('id', 'hidden')->add('name', 'text', array('property_path' => null, 'cascade_validation' => false)); }