public function saveFormEntry(FormBuilder_EntryModel $entry) { // Fire Before Save Event $this->onBeforeSave(new Event($this, array('entry' => $entry))); $entryRecord = new FormBuilder_EntryRecord(); $entryRecord->formId = $entry->formId; $entryRecord->title = $entry->title; $entryRecord->data = $entry->data; $entryRecord->validate(); $entry->addErrors($entryRecord->getErrors()); if (!$entry->hasErrors()) { $transaction = craft()->db->getCurrentTransaction() === null ? craft()->db->beginTransaction() : null; try { if (craft()->elements->saveElement($entry)) { $entryRecord->id = $entry->id; $entryRecord->save(false); if ($transaction !== null) { $transaction->commit(); } return $entryRecord->id; } else { return false; } } catch (\Exception $e) { if ($transaction !== null) { $transaction->rollback(); } throw $e; } return true; } else { return false; } }
public function populateElementModel($row, $normalize = false) { $entry = FormBuilder_EntryModel::populateModel($row); if ($normalize) { $entry = $entry->_normalizeDataForElementsTable(); } return $entry; }