function perch_forms_form_handler($SubmittedForm) { if ($SubmittedForm->validate()) { $API = new PerchAPI(1.0, 'perch_forms'); $Forms = new PerchForms_Forms($API); $formKey = $SubmittedForm->id; $Form = $Forms->find_by_key($formKey); if (!is_object($Form)) { $data = array(); $data['formKey'] = $formKey; $data['formTemplate'] = $SubmittedForm->templatePath; $data['formOptions'] = PerchUtil::json_safe_encode(array('store' => true)); $attrs = $SubmittedForm->get_form_attributes(); if ($attrs->label()) { $data['formTitle'] = $attrs->label(); } else { $data['formTitle'] = PerchUtil::filename($formKey, false); } $Form = $Forms->create($data); } if (is_object($Form)) { $Form->process_response($SubmittedForm); } } $Perch = Perch::fetch(); PerchUtil::debug($Perch->get_form_errors($SubmittedForm->formID)); }