Styling CI form_input |
[eluser]doubleplusgood[/eluser]
Hi there, Relatively simple question - i'm trying to find out how I can add a CSS Class or ID to a form_input like this; Code: <?=form_input('first_name', set_value('first_name'));?> Grateful for any solution. Thanky.
[eluser]ElShotte[/eluser]
If theyre all going to look the same, you can style the BASE input class (standard look for ANY fields on the page). Easier and faster that way too.
[eluser]guillermo, out of repose[/eluser]
That's in the user guide, bro: http://ellislab.com/codeigniter/user-gui...elper.html
[eluser]doubleplusgood[/eluser]
Hi, I tried the way from the user guide first, but it gave an undefined variable error. Using the following code in the view; Code: <?=form_input($data);?> and the following code in controller; Code: $data = array(
[eluser]guillermo, out of repose[/eluser]
how are you loading the view? If you're setting $data in the controller, then you need to load the view this way in your controller (also in the user guide): [pre] $data = array( 'name' => 'last_name', 'class' => 'text', 'value' => 'last_name'); $this->load->view('your_view', array('data'=>$data)); [/pre]
[eluser]doubleplusgood[/eluser]
This is how I am loading the View in my controller for signup; Code: function signup()
[eluser]guillermo, out of repose[/eluser]
You're not defining $data in your controller. Just do this and you'll be fine: [pre]<?=form_input(array('name' => 'last_name', 'class' => 'text', 'value' => 'last_name'));?>[/pre] |
Welcome Guest, Not a member yet? Register Sign In |