How to add a textfield in form with out model class??


I need to add a text field in YII form in which i am not specify any model class name. But I need to process that value in the action method inside the controller class.

Thanks in advance…

You can create a plain chtml textfield object, assign it an id, and it will be passed to the controller in the $_POST


check the parameters, if you name it mytextField the post int he controller will contain the value in $_POST[‘mytextField’]

edit: ah well, too late

Thanks for the reply but I am new to YII. I used the code as

<div class="row">

		<?php echo CHtml::textField("testvalue");?>


When i use


inside the action method in controller it is not contain the text field value…

The first parameter for CHTML::textField is the name, this is what you’ll need to reference when getting the $_POST value.

Try this…


<?php echo CHtml::textField('testvalue','This is the default value');?>



Does that mean you can’t read the docs ?

I mean i think it was clear enough if you would have looked at the docs,

no offense, just advise, try firebug too, then you would have been able to see what gets posted (and also what the code outputs but that’s that same as view source

Thank you Mukke…

(\ /)

( . .)

C(’’)(’’) –