Laravel 使用路由和控制器提交表单

Laravel form submit with route and controller

1.How 我可以将正确的路由转换成开放短语吗?

2.I 想要生成 URL: dgrs/2014-31-01.

仅查看文件中的表单:dgrs/show.blade.php

{{ Form::open(array('action'=>'DgrsController@ddgr')) }}
   Select Date: 
   {{ Form::input('date', 'dgrdate', $dt, array('class' => 'input-md')) }}
   {{ Form::submit('View', array('class'=>'btn btn-primary')) }}
{{ Form::close() }}

routes.php

Route::match(array('GET', 'POST'), 'dgrs/(:date)', ['as'=>'ddaily', 'uses'=>'DgrsController@ddgr']);

DgrsController.php

public function ddgr($date)
{

    $dt=isset($date) ? $date : date("Y-m-d");   //date selection from user
    ...

    return View::make('dgrs.show', compact('dfinal', 'dt'));
    //dfinal is db query and dt is selected date back to show.blade.php
}

查看的是表格文件:dgrs/show.blade.php

请指教

这是 jQuery

的解决方案
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>

{{ Form::open(array('action'=>'DgrsController@ddgr' , 'id' => 'myFrm')) }}
Select Date:
{{ Form::input('date', 'dgrdate', $dt, array('class' => 'input-md' , 'id' => 'txtDate')) }}
{{ Form::submit('View', array('class'=>'btn btn-primary')) }}
{{ Form::close() }}


<script>

$(document).ready(function(){

    $("#txtDate").change(function(){

        var baseUrl = "{{  URL::to("dgrs") }}" + "/" + $(this).val();

        $("#myFrm").attr("action",baseUrl);

    });

});

</script>

所以我所做的是,每当日期发生变化时,动作 url 就是根据该日期发生变化。