예제 #1
0
 public function editAction()
 {
     $form = new \DF\Form($this->current_module_config->forms->block->form);
     if ($this->hasParam('id')) {
         $id = (int) $this->getParam('id');
         $record = Block::find($id);
         $form->setDefaults($record->toArray(TRUE, TRUE));
     }
     if ($_POST && $form->isValid($_POST)) {
         $data = $form->getValues();
         if (!$record instanceof Block) {
             $record = new Block();
         }
         $record->fromArray($data);
         $record->save();
         $this->alert('Changes saved.');
         return $this->redirectFromHere(array('action' => 'index', 'id' => NULL));
     }
     $this->renderForm($form, 'edit', 'Edit Content Block');
 }