Yii Framework Forum: Default safe ? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Default safe ? Rate Topic: -----

#1 User is offline   Dariusz Męciński 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 04-March 09

Posted 07 May 2011 - 05:59 AM

Hello,
I noticed that my models now saving attributes not listed in safe validator.
Something changed and now default is safe ?
Is the way to set default safe or unsafe ?
0

#2 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,353
  • Joined: 12-October 09
  • Location:Croatia

Posted 07 May 2011 - 06:40 AM

Check the documentation - http://www.yiiframew...safe-attributes
Find more about me.... btw. Do you know your WAN IP?
0

#3 User is offline   Dariusz Męciński 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 04-March 09

Posted 07 May 2011 - 06:43 AM

ok, I added new column to table and its not listed in any validtaor, but $model->save() saving it with no problem.
0

#4 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,353
  • Joined: 12-October 09
  • Location:Croatia

Posted 07 May 2011 - 06:50 AM

How do you assign a value to that field?

"Safe" attributes are considered/used only for the "massive assignement"... not for saving...

read this part of the doc - http://www.yiiframew...te-assignments.
Find more about me.... btw. Do you know your WAN IP?
0

#5 User is offline   Dariusz Męciński 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 04-March 09

Posted 07 May 2011 - 06:56 AM


if(isset($_POST['Product']))
{                       
  $model->attributes=$_POST['Product'];                                             
  if($model->save()) {                                                                                              
    Yii::app()->user->setFlash('success',"Ok");
    $this->redirect(array('update','id'=>$model->id));
  }
}

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users