Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

customize form_open() to add elements

I using Codelginiter PHP MVC framework to develop a web application, i am trying to use form_open() instead of <form></form>, what i am trying to do is add class="navbar-form navbar-left" role="search" to it and seems it doesn't not work.

here is the code to make a form

<?php 
echo 
form_open('social_controller/search_me');
?>
like image 229
Bader H Al Rayyes Avatar asked Dec 02 '22 21:12

Bader H Al Rayyes


2 Answers

I'll quote a section from the documentation.

Attributes can be added by passing an associative array to the second parameter, like this:

$attributes = array('class' => 'email', 'id' => 'myform');
echo form_open('email/send', $attributes); 

It seems you have not tried adding an associative array as the second parameter? Try this:

echo form_open('social_controller/search_me', array(
    'class' => 'navbar-form navbar-left', 
    'role' => 'search'
));
like image 105
SamV Avatar answered Dec 09 '22 14:12

SamV


form_open('social_controller/search_me','class="Your Class" role="Your Role" attribute1="value1" attribute2="value2" ');
like image 25
UX Labs Avatar answered Dec 09 '22 16:12

UX Labs