function post_user()
{
$data = array(
'first_name' => input::post('first_name'),
'last_name' => input::post('last_name'),
'gender' => input::post('gender'),
'birth' => input::post('birth'),
'email' => input::post('email'),
'password' => input::post('password')
);
$user = new Model_user($data);
if($user->save()){
$this->response($data,201);
}else{
$this->response(null,500);
}
}
And this are the propertis on th Model_user:
protected static $_properties = array(
'id',
'first_name' => array(
'data_type' => 'varchar',
'label' => 'First Name',
'validation' => array('required', 'min_length' => array(3), 'max_length' => array(32)),
'form' => array('data_type' => 'text')
),
'last_name' => array(
'data_type' => 'varchar',
'label' => 'Last Name',
'validation' => array('required', 'min_length' => array(3), 'max_length' => array(100)),
'form' => array('data_type' => 'text')
),
'email' => array(
'data_type' => 'varchar',
'label' => 'E-mail',
'validation' => array('required', 'min_length' => array(3), 'max_length' => array(100)),
'form' => array('data_type' => 'text')
),
'gender' => array(
'data_type' => 'varchar',
'label' => 'Gender',
'form' => array('data_type' => 'select', 'options' => array('m' => 'Male', 'f' => 'Female')),
'validation' => array('required', 'min_length' => array(1), 'max_length' => array(1)),
),
'birth' => array(
'data_type' =>'date',
'label' => 'Birth Date',
'validation' => array('required')
),
'password' => array(
'data_type' => 'varchar',
'label' => 'Password',
'validation' => array('required')
)
);
If I send the 'first_name' empty it stills inserts the recordIt looks like you're new here. If you want to get involved, click one of these buttons!