protected function processForm(sfWebRequest $request, sfForm $form) { $fieldSc = $form->getFormFieldSchema(); $widget = $fieldSc->getWidget(); $params = array(); foreach ($widget->getFields() as $key => $object) { if ($key == "sf_guard_group_permission_list") { continue; } $data = $request->getParameter($key); $data_dec = json_decode($data); $params[$key] = is_array($data_dec) ? $data_dec : $data; } $form->bind($params); if ($form->isValid()) { try { $group = $form->save(); } catch (Exception $e) { $response = array('success' => false, 'error' => 'Could not perform operation', 'agent' => sfConfig::get('config_acronym'), 'info' => 'Could not perform operation'); return $response; } return array('success' => true, 'object' => $group->toArray()); } else { $errors = array(); foreach ($form->getFormattedErrors() as $error) { $errors[] = $error; } $error_msg = implode($errors); $info = implode('<br>', $errors); $response = array('success' => false, 'error' => $error_msg, 'agent' => sfConfig::get('config_acronym'), 'info' => $info); return $response; } }
protected function processJsonForm($request, sfForm $form) { $form->bind($request); if ($form->isValid()) { try { $etva_vlan = $form->save(); } catch (Exception $e) { $result = array('success' => false, 'error' => array('vlan' => $e->getMessage())); return $result; } //$result = array('success'=>true,'insert_id'=>$etva_server->getId()); $result = array('success' => true, 'object' => $etva_vlan); return $result; } else { error_log("CREATEVLAN[ERROR] Form is invalid"); $errors = array(); foreach ($form->getFormattedErrors() as $error) { $errors[] = $error; } $msg_err = implode('<br>', $errors); $err = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_err); $result = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => array($err)); return $result; } }