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;
 }
 protected function disableValidators(array $fields, $validators = null)
 {
     foreach ($fields as $field) {
         if (!$this->form->has($field)) {
             continue;
         }
         $fc_field = $this->fc_form->getFieldByName($field);
         if (!$fc_field instanceof FcField) {
             continue;
         }
         foreach ($fc_field->getConstraints() as $fc_constraint) {
             if (null === $validators || in_array($fc_constraint->getConstraint(), $validators)) {
                 $this->del_groups[] = $fc_constraint->getConstraint() . '_' . $fc_field->getId();
             }
         }
     }
 }
 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);
     }
 }
 public function clear(FcForm $fc_form, $options = array())
 {
     if (isset($this->forms[$fc_form->getAlias()])) {
         unset($this->forms[$fc_form->getAlias()]);
     }
     return $this->create($fc_form, $options);
 }
 protected function findDuplicates(FcForm $fc_form, &$fields)
 {
     foreach ($fc_form->getFcFields() as $fc_field) {
         if ($fc_field->isCustom()) {
             $this->findDuplicates($fc_field->getCustomWidget(), $fields);
         } else {
             if (!in_array($fc_field->getName(), $fields)) {
                 $fields[] = $fc_field->getName();
             } else {
                 throw new \Exception($this->translator->trans('fc.constraint.admin.not_unique_field_name', array(), 'validators'));
             }
         }
     }
 }
 protected function handleFields(FcForm $fc_form, $all = false, $list = false)
 {
     if (is_null($this->steps_count)) {
         $this->steps_count = 1;
     }
     foreach ($fc_form->getFields($all) as $fc_field) {
         $custom_widget = $fc_field->getCustomWidget();
         if ($custom_widget and $list) {
             $not_for_handle = $custom_widget->getIsWidget();
         } else {
             $not_for_handle = 0;
         }
         if ($fc_field->isCustom() && !$not_for_handle) {
             $this->handleFields($custom_widget, $all);
         } else {
             if ('hidden' == $fc_field->getType()) {
                 $fc_field->setStep(1);
                 $this->fields = array($fc_field->getName() => $fc_field) + $this->fields;
             } else {
                 $fc_field->setStep($this->steps_count);
                 $this->fields[$fc_field->getName()] = $fc_field;
             }
             if ('step' == $fc_field->getType()) {
                 $this->steps_count++;
             }
         }
     }
 }