如何在 Laravel 4 的表单中使用 Twitter Bootstrap?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20142498/
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
How can I use Twitter Bootstrap in forms with Laravel 4?
提问by user1686123
I've added bootstrap css and js files to my laravel 4 layout. How can I use it in the forms? Is there any package or tutorial? I found some old bundles but no composer packages... Can someone help me please?
我已经将 bootstrap css 和 js 文件添加到我的 laravel 4 布局中。如何在表格中使用它?有包或者教程吗?我找到了一些旧包但没有作曲家包...有人可以帮我吗?
Thanks
谢谢
回答by clod986
Personally, I use twitter bootstrap from the CDN therefore no need to install packages. To use it in form, just pass the CSS class once calling the FORM
helper.
就个人而言,我使用来自 CDN 的 twitter bootstrap,因此无需安装软件包。要在表单中使用它,只需在调用FORM
帮助器时传递 CSS 类。
A login example:
登录示例:
Form::open(['route' => 'login', 'method' => 'post', 'class' => 'clearfix'])
Form::email('email', '', array('class' => 'form-control', 'placeholder' => 'Email'))
Form::password('password', array('class' => 'form-control', 'placeholder' => 'Password'))
Form::submit('Login', array('class' => 'btn btn-primary'))
Form::close()
回答by JofryHS
I think Formeris what you are looking for. It inherently capable of structurally creating form based on Twitter Bootstrap.
我认为前者是你正在寻找的。它本质上能够基于 Twitter Bootstrap 在结构上创建表单。
Example taken directly from the github page:
直接取自github页面的示例:
Former::horizontal_open()
->id('MyForm')
->secure()
->rules(['name' => 'required'])
->method('GET')
Former::xlarge_text('name')
->class('myclass')
->value('Joseph')
->required();
Former::textarea('comments')
->rows(10)->columns(20)
->autofocus();
Former::actions()
->large_primary_submit('Submit')
->large_inverse_reset('Reset')
Former::close()