Yii Framework Forum: CActiveRecord.setAttributes - Yii Framework Forum

Jump to content

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

CActiveRecord.setAttributes Rate Topic: -----

#1 User is offline   notzippy 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 201
  • Joined: 06-October 08

Posted 14 October 2008 - 10:17 AM

Hi

I was wondering if it was possible to modify the setAttributes method to allow passing in an array of allowed attributes to be set. Like
CActiveRecord.setAttributes($_POST['User'],true, array('name','email'))

I know you can exclude a particular number of attributes using the "protectedAttributes"  method but the attributes you may want to allow to be set could be different based on the role of the person, or even the state of the record. So the controller should also be allowed to specify which attributes may be updated.

nz
0

#2 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,875
  • Joined: 04-October 08
  • Location:DC, USA

Posted 14 October 2008 - 10:56 AM

Good suggestion. Done.
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