I’m reading a lot and getting really mixed results.
Say I have code like this?
$name = trim($_POST['name']);
$email = trim($_POST['email']);
if(strlen($name) > 0 & strlen($email) > 0)
{
$u = new User();
$u.name = $name;
$u.email = $email;
$u.validate();
}
Where should this code live? The code that actually checks the form to make sure it has actual values? I say Model, but then what if your form spans across multiple models?
I’m a bit confused and any help to clear it up would be appreciated.
Ideally for the complete separation of concerns:
The
Controllershould be collecting the$_POSTarray and passing it to theModel.Then the
modelwould do the processing such as trim and validating.I would +1 that the Model contains business logic.