/** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $aggregate = [Field::AGGREGATE_COUNT, Field::AGGREGATE_AVG, Field::AGGREGATE_SUM, Field::AGGREGATE_MIN, Field::AGGREGATE_MAX]; $aggregate = array_combine($aggregate, $aggregate); $fields = $this->store->getColumns(); $fields = array_combine($fields, $fields); $builder->add('field', 'choice', ['choices' => $fields, 'attr' => ['class' => 'aggragate_field', 'onChange' => 'rebuildOrderField()']])->add('aggregate', 'choice', ['required' => false, 'choices' => $aggregate, 'empty_value' => '[none]', 'attr' => ['class' => 'aggragate_select', 'onChange' => 'rebuildOrderField()']]); }
/** * @Route("/table/new", name="store_new") * @Method({"GET", "POST"}) * @Template() */ public function newAction(Request $request) { $app = $this->getApp($request); $appParams = $this->getExtensionAppParameters($request); $store = new Store(); $store->setApp($app); $form = $this->createForm(new StoreType(), $store, array('action' => $this->generateUrl('store_new', $appParams), 'method' => 'POST')); $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($store); $em->flush(); return $this->redirect($this->generateUrl('store_list', $appParams)); } $data = ['store' => $store, 'form' => $form->createView(), 'appParams' => $appParams]; return $data; }
protected function settingsAction(Request $request) { $app = $this->getApp($request); if (!$app->getStores()->count()) { $defaultStore = new Store(); $defaultStore->setName('Default'); $defaultStore->setApp($app); $app->addStore($defaultStore); $em = $this->getDoctrine()->getManager(); $em->persist($defaultStore); $em->flush($defaultStore); } $form = $this->createForm(new ViewType($app), $this->getView($request)); if ($request->getMethod() == 'POST') { $form->handleRequest($request); if ($form->isValid()) { $this->get('session')->getFlashBag()->add('success', 'Your changes were saved'); $this->getDoctrine()->getManager()->flush(); } } return ['form' => $form->createView(), 'appParams' => $this->getExtensionParameters($request)]; }
/** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('col', 'choice', ['choices' => $this->arrayWithKeys($this->store->getColumns())])->add('type', 'choice', ['choices' => $this->arrayWithKeys([Filter::FILTER_EQUALS, Filter::FILTER_GREATER_THAN, Filter::FILTER_GREATER_THAN_OR_EQUALS, Filter::FILTER_LESS_THAN, Filter::FILTER_LESS_THAN_OR_EQUALS])])->add('value'); }