예제 #1
0
 public function delete(\Rapid\Model $model)
 {
     if (!($id = $model->id())) {
         return false;
     }
     return $this->db()->delete($this->tablename, array('id' => $id));
 }
예제 #2
0
 protected function getValueByModelAndName(array $data)
 {
     if (!isset($data[$this->model->name()][$this->elementName])) {
         throw new \Rapid\Form\Validator\Exception\DoesntExist();
     }
     return $data[$this->model->name()][$this->elementName];
 }
예제 #3
0
파일: Form.php 프로젝트: creogen/rapidphp
 /**
  * Build name for element.
  *
  * @param string $name
  *
  * @return string
  */
 protected function elementName($name)
 {
     return $this->model ? sprintf('%s[%s]', $this->model->name(), $name) : $name;
 }
예제 #4
0
 /**
  * @depends testCreate
  */
 public function testSetProperties()
 {
     $model = new \Rapid\Model();
     $this->assertEquals(array(), $model->properties(), 'Properties of new model are not empty');
     $properties = array('my' => 1, 'another' => 'string');
     $model->setProperties($properties, true);
     $this->assertEquals($properties, $model->properties(), 'Properties don\\t match');
     $this->assertEquals(array(), $model->modifiedProperties(), 'Modified properties are incorrect');
     $modifiedProperties = array('my' => 2);
     $model->setProperties($modifiedProperties);
     $this->assertEquals(array_merge($properties, $modifiedProperties), $model->properties(), 'Properties don\\t match');
     $this->assertEquals($modifiedProperties, $model->modifiedProperties(), 'Modified properties are incorrect');
     $model->setProperty('new', 1);
     $this->assertEquals(1, $model->property('new'), 'Property not set');
     $this->assertEquals(array_merge($modifiedProperties, array('new' => 1)), $model->modifiedProperties(), 'Modified properties are incorrect');
 }