Accessing a model attribute in beforeSave()

Hi

Is there any method that i can access the attributes of the model in beforeSave() method.

example

if i have a model Post have attributes like

id,title, body,create_time etc all these are not NULL

saving datetime using beforeSave()

What i want is to Access the title of model post entered in textField here.that was entered in _form.

In your post model in the beforeSave()

just call $this->title;

First you are required to set the attributes: $model->attributes = $_FORM[‘modelname’], then you can access them as EdoFree states

onBeforeSave… you do




public beforeSave(){

   if(parent::beforeSave()){

   {

         // for example

        $this->date = time(); // if you save dates as INT

        return true;

   }

   return false;

}



thanks all man

hola antonio, saludos, serian tan amable de dar tu valiosa opinion en el siguiente post, ya que empiezo con yii y necesito actualizar solo los campos que se modifican en un determinado UPDATE…

lo realize de la siguiente manera y funciono, pero siempre es bueno la opinion de expertos…

hilo del post… http://www.yiiframework.com/forum/index.php/topic/46126-opinion-auditoria-sin-beforesend-ni-afterfind/

saludos , estare agradecido de tu ayuda