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.
Edofre
(Edofre)
April 6, 2011, 11:17am
2
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;
}
apositivo
(Mike Ro)
August 14, 2013, 6:01am
5
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;
}
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