protected function getColumnsChoices() { $choices = array(); foreach ($this->fc_form->getFieldsRecursively(true) as $fc_field) { $choices[$fc_field->getId()] = (string) $fc_field; } return $choices; }
protected function makeData() { $result = array(); $data = $this->event->getData(); foreach ($data as $key => $value) { if (preg_match('/^_[^_]/', $key)) { unset($data[$key]); } } foreach ($this->fc_form->getFieldsRecursively() as $fc_field) { if (!isset($data[$fc_field->getName()]) || empty($data[$fc_field->getName()])) { continue; } $result[] = array('name' => $fc_field->getName(), 'type' => $fc_field->getType(), 'label' => $fc_field->getLabel(), 'value' => $this->makeValue($fc_field, $data), 'templates' => $this->fc_form->getFieldTemplates($fc_field->getName())); } return $result; }
public function buildForm(FormBuilderInterface $builder, array $options) { foreach ($this->fc_form->getFieldsRecursively() as $fc_field) { $this->addField($builder, $fc_field); } $action = $this->fc_form->getAction(); if ($this->router->getRouteCollection()->get($action) !== null) { $action = $this->router->generate($action); } if ($this->fc_form->getIsAjax()) { if (empty($action)) { $action = $this->router->generate('fc_from_ajax_handler', array('alias' => $this->fc_form->getAlias())); } } $builder->add('submit', 'submit', array('label' => $this->fc_form->getButton() ? $this->fc_form->getButton() : 'fc.label.button'))->add('_template', 'hidden')->setMethod($this->fc_form->getMethod())->setAction($action); $save_handler = new SaveRequestHandler($this->field_chain, $this->fc_form); $builder->addEventListener(FormEvents::POST_SUBMIT, array($save_handler, 'handle')); foreach ($this->fc_form->getListeners() as $fc_listener) { $this->addListener($builder, $fc_listener); } }