如何使用codeigniter form helper添加属性 [英] How to add attributes using codeigniter form helper
本文介绍了如何使用codeigniter form helper添加属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法找到答案。假设我使用代码点火器表单助手输出一个输入字段:
echo form_input('username','username');
如何添加属性,如 class
或 id
到输入
提交?
解决方案
你可以传递一个包含希望表单包含的任何数据的关联数组:
试试这个
$ data = array(
'name'=>'username',
'id'=>'username',
'class'=>'username',
'value'=>'username',
);
echo form_input($ data);
请仔细阅读用户指南。在那里用例子明确提到。 链接到用户指南
I can't find the answer to this. Say I output a input field using the code igniter form helper:
echo form_input('username','username');
How do I add attributes such as class
or id
to that input
filed?
解决方案
you can pass an associative array containing any data you wish your form to contain:
try this
$data = array(
'name' => 'username',
'id' => 'username',
'class' => 'username',
'value' => 'username',
);
echo form_input($data);
Please go through the userguide. it is clearly mentioned there with examples. link to userguide
这篇关于如何使用codeigniter form helper添加属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文