public function doConfigureAction(Request $request, $form_id)
 {
     try {
         if (!$request->isXmlHttpRequest()) {
             throw $this->createNotFoundException();
         }
         $fc_form = FcFormQuery::create()->findPk((int) $form_id);
         if (!$fc_form instanceof FcForm) {
             throw $this->createNotFoundException('Form not found');
         }
         $form_action = $this->admin->generateUrl('do_configure', array('form_id' => $fc_form->getId()));
         $form = $this->createForm(new RequestCommonType($form_action, $fc_form), FcRequestSettingQuery::create()->filterByFcForm($fc_form)->findOneOrCreate());
         $form->handleRequest($request);
         if ($form->isValid()) {
             /** @var FcRequestSetting $setting */
             $setting = $form->getData();
             $setting->save();
             return new JsonResponse(array('success' => true));
         }
     } catch (\Exception $e) {
         return new JsonResponse(array('success' => false, 'view' => 'Error ' . $e->getCode() . ': ' . $e->getMessage()));
     }
     return new JsonResponse(array('success' => false, 'view' => $this->renderView('FenrizbesFormConstructorBundle:SonataAdmin/FcForm:form.html.twig', array('form' => $form->createView()))));
 }
 protected function getCustomColumns()
 {
     $out_columns = array();
     $setting = FcRequestSettingQuery::create()->findOneByFormId($this->getFcForm()->getId());
     if (!$setting instanceof FcRequestSetting) {
         return;
     }
     $settings = $setting->getSettings();
     if (!is_array($settings) || !isset($settings['columns']) || !is_array($settings['columns'])) {
         return;
     }
     foreach ($settings['columns'] as $fc_field_id) {
         $fc_field = FcFieldQuery::create()->findPk($fc_field_id);
         if (!$fc_field instanceof FcField) {
             continue;
         }
         $out_columns['Data_' . $fc_field->getName()] = $fc_field;
     }
     return $out_columns;
 }