php 如何在 YII 中没有模型类的情况下在表单中添加文本字段?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5104388/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to add a textfield in form with out model class in YII?
提问by Damodaran
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.
我需要以 YII 形式添加一个文本字段,其中我没有指定任何模型类名称。但是我需要在控制器类中的 action 方法中处理该值。
ie
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...
但我不想在新文本字段中指定任何型号名称.. 提前致谢...
采纳答案by Mikelangelo
You can add a Chtml textfieldwith an id
您可以添加带有 id的Chtml 文本字段
It will the show in the: $_POST['mytextField']
它将显示在:$_POST['mytextField']
回答by Shekhar
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']
这将为您提供 $_POST['User'] 中的文本值作为 $_POST['User']['textvalue']