douwa0280 2016-01-11 22:21
浏览 51
已采纳

laravel 5.1表单和路由问题

Hi i am trying to get the output from my form to save and even when i try to echo(print_r) the output it but it simply goes to the post request and does not echo any output.

my route looks like:

Route::controller('stove', 'StoveController', [
    'anyData'  => 'stove.data',
    'getIndex' => 'stove',
]);

Route::get('newstove', 'StoveController@addData');
Route::post('newstove', 'StoveController@store');

my controller:

public function addData()
{

    return view('stoves.new');
}

public function store()
{
    $input = Request::all();
    Stove::create($input);

    return redirect('stove');
}

and finally my form is

<form class="form-horizontal" action="/stove">
    <fieldset>
        <div class="control-group">
            <label class="control-label" for="stoveno">Stove Number</label>
            <div class="controls">
                <input type="text" class="span4" id="stoveno" value="CP001000">
            </div> <!-- /controls -->
        </div> <!-- /control-group -->

        <div class="control-group">
            <label class="control-label" for="refno">Ref Number</label>
            <div class="controls">
                <input type="text" class="span4" id="refno" value="cff001">
            </div> <!-- /controls -->
        </div> <!-- /control-group -->

        <div class="control-group">
            <label class="control-label" for="manufacturedate">Manufacture Date</label>
            <div class="controls">
                <input type="date" class="span4" id="manufacturedate">
            </div> <!-- /controls -->
        </div> <!-- /control-group-->

        <div class="form-actions">
            <button type="submit" class="btn btn-primary">Save</button>
            <button class="btn">Cancel</button>
        </div> <!-- /form-actions -->
    </fieldset>
</form>

Thanks

  • 写回答

2条回答 默认 最新

  • duang5049 2016-01-11 22:32
    关注

    Change the first line of your form to the following..

    <form class="form-horizontal" action="/newstove" method="post">
    

    This should submit your form via the POST method to the last route in your routes file.

    From what I can see the first part of your routes file is not required...

    Route::controller('stove', 'StoveController', [
       'anyData'  => 'stove.data',
       'getIndex' => 'stove',
    ]);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序