How To Access Form Element In Controller

How can I access the elements of my view in controller. lets I have a field name ‘type’ in my form field and I want to access the value of that field in my controller class. How can I achieve that. I saw where we are fetching all attributes

$model->attributes=$_POST[‘Alerts’];

How can I get a specific attribute from $model->attributes Thanks in advance

I want to pass a value from form to the model.

Getting One value from the form




$alerts=$_POST['Alerts'];

echo $alerts['property'];



// setting one value to model




$model->setAttributes(array(

'property'=>'value'

));



Further reading

http://www.yiiframework.com/doc/api/1.1/CModel#setAttributes-detail

thanks

hi

you can access it directly by




$var=$_POST['Alerts']['type']; 



or




$model->attributes=$_POST['Alerts']; 

$var=$model->type;

attribute type must be defined in model class or it must be part of table related to model class