Using magic property to store related records has a problem when the related record fails to vaidate, it out put _postSaveRelalated bla bla error.
So the doc example below,
$artist = new Artists(); $artist->country = 'Japan'; $album = new Albums(); $album->name = 'The One'; $album->artist = $artist; //Assign the artist $album->year = 2008; //Save both records $album->save();
If the Artist validation fails, the save operation in album model would produce
Fatal error: Phalcon\Mvc\Model::_postSaveRelatedRecords(): Call to method setmodel() on a non object in ....
My question is how to store related record like the example docs without producing this fatal error