Skip to content

Make massive assignment work with setters in CActiveRecords #1245

mikehaertl opened this Issue Aug 17, 2012 · 1 comment

2 participants


If you have an ActiveRecord with custom setters like this:

class MyRecord extends CActiveRecord
    public function setTest($value)
        $this->something = $value;

then you can't assign test with massive assignment:

$model = new MyRecord;
    'test' => 'testvalue',

because in CActiveRecord::setAttributes() we use property_exists(), which does not detect getters/setters:

    public function setAttribute($name,$value)
        else if(isset($this->getMetaData()->columns[$name]))
            return false;
        return true;

This is an unneccesary limitation i think. It also works for CFormModel so why not make it work for ActiveRecords, too?

Yii Software LLC member
cebe commented May 27, 2013

Closed for reasons described in #1708 .

@cebe cebe closed this May 27, 2013
@cebe cebe was assigned May 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.