rknalajala
(Ramakrishnanalajala)
May 28, 2011, 8:07am
1
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.
lidiexy
(Lidiexy)
May 28, 2011, 9:27am
2
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().
rknalajala
(Ramakrishnanalajala)
May 28, 2011, 10:11am
3
same error is displayed if i add dynamicstates to rules.
tri
(tri - Tommy Riboe)
May 28, 2011, 10:19am
4
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
rknalajala
(Ramakrishnanalajala)
May 28, 2011, 11:40am
5
tri:
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.
lidiexy
(Lidiexy)
May 28, 2011, 5:18pm
6
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.