当我在Laravel 4 API中搜索时,例如:
Form::open(array $options = array())
我找不到可用选项的完整列表?到哪里去找呢?
http://laravel.com/api/4.1/Illuminate/Html/FormBuilder.html method_open
谢谢,
method
, action
, files
, url
和route
的具体选项参见下面的链接
http://laravel.com/api/source-class-Illuminate.Html.FormBuilder.html # 63
它们的用法在这里解释
http://laravel.com/docs/html打开表单
选项为:
- 方法: POST, GET, PUT, PATCH, DELETE。后三种方法用隐藏字段进行欺骗。
-
action:设置
action='...'
属性。如果还有url
、route
选项,它们将被翻译成适当的URL。否则,action
应该指向Controller操作路由。如果不存在,动作默认为当前URL。 - accept-charset:强制为UTF-8
-
files:如果存在文件上传,可以是
true
,将enctype = 'multipart/form-data'
附加到表单中。
与您希望添加的任何选项(如"id", "enctype"或类似)。
您可能应该查看laravel官方文档
http://laravel.com/docs/html查看源代码:https://github.com/laravel/framework/blob/master/src/Illuminate/Html/FormBuilder.php#L95
一些复杂的形式:
Form::open(['method' => 'put', 'action' => 'awesomeController@putForm', 'id' => 'my-id', 'class' => 'some more css classes', 'files' => 'true', 'data-url' => 'This could be read in JavaScript']);
method
, action
和files
是Laravel特有的,其他值只是属性和值。
选项列表与未使用php的表单列表相同:
http://www.w3schools.com/tags/tag_form.asp不同的是属性将以数组格式传递:
array('action' => 'user. ')更新"、"enctype ' => '多部分/格式"、"方法"=>"放")
如果没有指定,默认的方法是POST。
@edit
好像我没说清楚。
Laravel只包括一些属性来帮助,如何url(转换为动作),路由(转换为动作),文件(转换为enctype='multipart/form-data'),但还是一样的。
文件到enctype转换:
if (isset($options['files']) && $options['files'])
{
$options['enctype'] = 'multipart/form-data';
}