简体   繁体   中英

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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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