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.
Page 1 of 1
How To Access Form Element In Controller
#2
Posted 16 January 2013 - 11:11 PM
Getting One value from the form
// setting one value to model
Further reading
http://www.yiiframew...tributes-detail
thanks
$alerts=$_POST['Alerts']; echo $alerts['property'];
// setting one value to model
$model->setAttributes(array( 'property'=>'value' ));
Further reading
http://www.yiiframew...tributes-detail
thanks
#3
Posted 17 January 2013 - 01:28 AM
hi
you can access it directly by
or
attribute `type` must be defined in model class or it must be part of table related to model class
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
Share this topic:
Page 1 of 1

Help













