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

Hi

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

CHtml::textField()

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");?>

	</div>

When i use


var_dump($_POST['User']);

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…

View:


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

Controller:


var_dump($_POST['testvalue']);

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(’’)(’’) –