How to access to a model attribute in beforeSave() method

Hello. I have this doubt:

in my model, I have this attribute:




protected $date_end;

Now, in the form file, I have this code:


       <?php echo $form->labelEx($model,'date_end'); ?>

        <?php echo $form->textField($model,'date_end'); ?>



So, when click “Save” button, I need to access to the ‘date_end’ model attribute.

I have this, but $this->date_end prints blank and doesn’t work:


    protected function beforeSave()

    {

        

        if(parent::beforeSave())

        {

            Yii::trace("Date:".$this->date_end,"file");        

            return true;

        }

        else

            return false;

    }

What’s the correct manner to access to my model attribute just when saving?

Did you declare a rule for that attribute?? (in method rules() of the model) If not, then the atribute is not fase, and thus, is not massively assigned.

WoW PoL, you are a Machine!!. Thanks, I’ve declared it as ‘safe’ in rules() and it works!. Thanks.

;) you are welcome!