Question about safeAttributes

Hi I’m going through the blog tutorial 1.1a

on page 17 a method called safeAttributes is discussed the text tells me to modify this method (but it is not created by yiic)

Do I have to create a method called safeAttributes like this


    public function safeAttributes()

    {

        return array('ismenu','ispublished','isvisible','iscontainer');

    }



or is this line doing exactly the same thing?


array('ismenu, ispublished, isvisible, iscontainer', 'safe'),

in this yiic generated method


	public function rules()

	{

		// NOTE: you should only define rules for those attributes that

		// will receive user inputs.

		return array(

			array('name, linktext, linkurl, description, acl', 'required'),

			array('title', 'required','message'=>'Custom message for title'), // my mod

			array('linkindex, acl', 'numerical', 'integerOnly'=>true),

			array('name, menu, pageparent', 'length', 'max'=>50),

			array('linktext', 'length', 'max'=>30),

			array('linkurl', 'length', 'max'=>200),

			array('description, title', 'length', 'max'=>160),

			array('ismenu, ispublished, isvisible, iscontainer', 'safe'),

		);

	}

 

Is it possible the blog demo is out of date regarding this?

doodle

yii 1.1 has no longer the safeAttributes() method. just make sure the attribute has a validation rule (rules()). attributes that don’t need a validation rule just assign safe to them. see Email and Priority.

see also http://www.yiiframework.com/doc/guide/upgrade#changes-related-with-model-scenarios




    public function rules()

    {

        return array(            

            array('CityId, Daytrip, Street, Number, ZipCode, Website, Categories, Tags, Active', 'required'),

            array('Email, Priority', 'safe'),

        );

    }