public function editAction() { $form = new \DF\Form($this->current_module_config->forms->convention); if ($this->hasParam('id')) { $id = (int) $this->getParam('id'); $record = Record::find($id); $form->setDefaults($record->toArray(TRUE, TRUE)); } if ($_POST && $form->isValid($_POST)) { $data = $form->getValues(); if (!$record instanceof Record) { $record = new Record(); } $files = $form->processFiles('conventions'); foreach ($files as $file_field => $file_paths) { $data[$file_field] = $file_paths[1]; } $record->fromArray($data); $record->save(); $this->_flushConventionCache(); $this->alert('Changes saved.', 'green'); return $this->redirectFromHere(array('action' => 'index', 'id' => NULL)); } $this->renderForm($form, 'edit', 'Edit Record'); }