Welcome Guest, Not a member yet? Register   Sign In
Validating in Controller vs Model
#1

[eluser]animatora[/eluser]
Hi all, I recently bought this book of Jamie "Codeigniters hand book". There he is making some very good observations about how should a model and controller look like. Has anyone come across his Model implementation on github, I can't understand how to make data validation.

Lest say I have this in my controller:

Code:
public function create()
{

$data = array(
'email' => $this->input->post('email'),
'first_name' => $this->input->post('first_name')
);

// How to perform insertion here, so I can send back to my view success or error messages
// $this->model_name->create($data);
// OR I have to run validation from the model and then insert data.
}

My model has all the validation setup in the crete method I just call the super insert like:

Code:
public function create($data)
{
return $this->insert($data);
}

Any help is appreciated


Messages In This Thread
Validating in Controller vs Model - by El Forum - 03-16-2012, 12:43 AM
Validating in Controller vs Model - by El Forum - 03-16-2012, 03:33 PM
Validating in Controller vs Model - by El Forum - 03-16-2012, 03:41 PM
Validating in Controller vs Model - by El Forum - 03-16-2012, 06:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB