自定义 form_open() 以添加元素


customize form_open() to add elements

我使用Codelginiter PHP MVC框架开发Web应用程序,我正在尝试使用form_open()而不是<form></form>,我正在尝试做的是向其添加class="navbar-form navbar-left" role="search",似乎它不起作用。

这是制作表单的代码

<?php 
echo 
form_open('social_controller/search_me');
?>

我将引用文档中的一节。

可以通过传递关联来添加属性 数组到第二个参数,如下所示:

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

您似乎还没有尝试添加关联数组作为第二个参数?试试这个:

echo form_open('social_controller/search_me', array(
    'class' => 'navbar-form navbar-left', 
    'role' => 'search'
));
form_open('social_controller/search_me','class="Your Class" role="Your Role" attribute1="value1" attribute2="value2" ');