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

家住魔仙堡 提交于 2019-12-21 05:08:14

问题


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.

ie

I need to add a text field as

<div class="row">
    <input type="text" name="test" id="test" >
</div>

I add text field as

<?php echo $form->textField($model['groupModel'],'group_name',array('size'=>60,'maxlength'=>128)); ?>

But i do't want to specify any model name with the new text field.. Thanks in advance...


回答1:


You can add a Chtml textfield with an id

It will the show in the: $_POST['mytextField']




回答2:


This should work

<div class="row">
    <?php echo CHtml::textField('User[textvalue]', '', array('size'=>60,'maxlength'=>128)); ?>                
</div>

This will give you the text value inside $_POST['User'] as $_POST['User']['textvalue']



来源:https://stackoverflow.com/questions/5104388/how-to-add-a-textfield-in-form-with-out-model-class-in-yii

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!