twitter-bootstrap 自定义 form_open() 以添加元素
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19879933/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
customize form_open() to add elements
提问by Bader H Al Rayyes
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.
我使用 Codelginiter PHP MVC 框架来开发 Web 应用程序,我试图使用form_open()而不是<form></form>,我试图做的是添加class="navbar-form navbar-left" role="search"到它,似乎它不起作用。
here is the code to make a form
这是制作表格的代码
<?php
echo
form_open('social_controller/search_me');
?>
回答by SamV
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'
));
回答by UX Labs
form_open('social_controller/search_me','class="Your Class" role="Your Role" attribute1="value1" attribute2="value2" ');

