Welcome Guest, Not a member yet? Register   Sign In
how to validate several models (parent model and child model)
#1
Question 

If one of the two does not validate, that neither insert data.

example:

if($this->carsModel->save($data))
{
    if($this->carsItemsModel->save($dataItems))
    {
        echo 1;
    }
    else
    {
        echo $this->carsItemsModel->errors();
    }
}
else
{
    echo $this->carsModel->errors();
}


the problem is that if the item is not validated, however you want it inserts the parent.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB