/** * Method to save the form data. * * @param array $data The form data. * * @return boolean True on success, False on error. */ public function save($data) { $result = parent::save($data); // Reorder if ($result && $this->state->get('order.position') == 'first') { $pk = $this->state->get($this->getName() . '.id'); $this->reorder(array($pk), array(0)); $this->state->set('order.position', null); } return $result; }
/** * Method to test save(). * * @return void * * @covers Windwalker\Model\CrudModel::save */ public function testSaveWithoutId() { $crudModel = new CrudModel(array('name' => 'CrudModel', 'prefix' => 'Stub', 'ignore_request' => true), $this->getContainerForSave()); $toSaveWithoutId = array('foo' => 'badGirl', 'type' => 'badGirlType', 'params' => array('name' => 'badGirlName')); $crudModel->save($toSaveWithoutId); $item = $crudModel->getItem(); $this->assertEquals($toSaveWithoutId['foo'], $item->foo); $this->assertEquals($toSaveWithoutId['type'], $item->type); $this->assertEquals($toSaveWithoutId['params'], $item->params); }