简体   繁体   English

如何使用codeigniter表单助手添加属性

[英]How to add attributes using codeigniter form helper

I can't find the answer to this. 我找不到答案。 Say I output a input field using the code igniter form helper: 假设我使用代码igniter表单助手输出一个输入字段:

echo form_input('username','username');

How do I add attributes such as class or id to that input filed? 如何向该input字段添加classid等属性?

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 链接到userguide

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM