yiiext/with-related-behavior — Issue #5: Will this work with an array of keys instead of objects?
Author: kenrestivo
Created: 2011-11-16 06:55:03+00:00
State: open

In handling real-world use (not unit test), the data will be an array of text from checkbox inputs, via HTTP, such as Post[Tag]1, Post[Tag]2, etc., showing up as $_POST['Post']['Tag'] which is array('1','2','3', etc). They won't be objects.

How would I assign the POST results to the object and have it save the relations? Like,
$model->tags = $_POST['Post']['Tag'];
$model->withRelated->save(true, array('tags')) ?

I tried the above to see if it would work, and it died at line 65 of WithRelated.php, it could not run validate method on non-object. So instead I tried $model->withRelated->save(false, array('tags')) , and it still died in the same place, trying to run validate method on non-object.