code issue

i have placed a code in controller which is called from view with help of $this keyword.




public function actionDynamicstates()

    {

        $data = Worldareastates::model()->findAll('countryid=:id',

                        array(':id'=>(int) $_POST['wsmembersdetails']['countryid']));




        $data = CHtml::listData($data,'id','name');

            foreach($data as $id => $value)

            {

                echo CHtml::tag('option',array('value' => $id),CHtml::encode($value),true);

            }


    }



when i run it is giving an error "Undefined index: wsmembersdetails".what does this mean.

wsmembersdetails is my table and countryid is column name in worldareastates table.

I asume that you read this article.

and you add the "dynamicstates" view to accessRules().

same error is displayed if i add dynamicstates to rules.

It looks like you would want to use one of the CHtml active type of inputs/dropdown/…

From the way you access the POST variable in your controller, you probably expected a model of class wsmemberdetail. (Model class names should start with an upper case letter.)

(I think you can find a lot of of examples searching the forum)

/Tommy

how to write code based on cform model in yii without using model attributes.

Nevertheless you must keep dynamicstates view on accessRules.

Please post the your ajax request, cause maybe you dont need call $_POST[‘wsmembersdetails’][‘countryid’], instead $_POST[‘countryid’] only.

Best Regards.