Problem about activetextfield

Hi everyone. As I glanced through the examples on the net concerning about activetextfield, they all obtained the data input in the form by $_POST[‘ModelClass’]… however this seems not to work for me.

I have a CMS form and I want to use activeTextField for the input data so that i can collect all the data related to the same database table at once. Currently my form only contains field that related to the same table. Therefore, the form contains several activeTextField with the same $model as the first parameter.

Assuming that the $model is of the class “Test”, why can’t i get anything from $_POST[‘Test’]? I tried print_r($_POST) and all i found were names of the activeTextFields, instead of the name of the model class.

Can anyone briefly explained what should be done in order to get the input data from activeTextField as a model variable???

Don’t really understand you issue because you didn’t show any code, particullary the way you create those fields.

However, doing:




$model=new MyModel;

echo CHtml::activeTextField($model,'name');



Will populate the $_POST with MyModel so you can access $_POST[MyModel][name];

yah… my bad for not having any codes…

but actually what i’m doing is almost the same as the example you provided… just that i have a model rendered from the controller.

And i seem to found the issue… i guess it was because i have specified another name activeTextField in the Html options array, and thus the function of passing data in the form of a model variable have been unintentionally disabled.

Does anyone have any further details about this issue?

Thanks for the concerns twisted1919


echo CHtml::activeTextField($model, 'attribute_name', array('name'=>'field_one'));