【问题标题】:Laravel form with RESTful Controller: "Some mandatory parameters are missing"带有 RESTful 控制器的 Laravel 表单:“缺少一些强制参数”
【发布时间】:2013-11-17 18:02:49
【问题描述】:

我不断收到此错误“缺少一些强制参数”,我找不到解决方法。

这是我的数据控制器:

//use some models here for Trialdata, Sessions, Rat;
class DataController extends \BaseController {

 //Some functions

public function destroy($id)
{
            Trialdata::where('id', $id)->delete();
            Sessions::where('id', $id)->update(array('sD_reason', 'Excluded'));
            Sessions::where('id', $id)->delete();
            Rat::where('id', $id)->update(array('sD_reason', Input::get('sD_reason')));
            Rat::where ('id', $id)->delete(); 
            //
}
}

这是我的路线:

Route::resource('data', 'DataController');

这是我认为的形式:

{{Form::open(array('route' => 'data.destroy', $parameters = array($entry[0]->id)))}}

    {{Form::label('sD_reason', 'Please specify the reasons of the exclusion');}}<br>
    <input name="sD_reason" type="text" id="sD_reason"> 
    <button type="button">No, thanks</button>
    <button type="submit" href="#">Exclude</butfon>

{{ Form::close() }}

我四处寻找类似的问题,我相信它在我的Form::open 中,但我找不到正确的语法。

【问题讨论】:

  • $parameters = array($entry[0]->id - 你想在那里做什么?这是关联数组中的乱码
  • 我正在尝试将我的$id 传递给我的DataController@destroy

标签: forms rest controller laravel


【解决方案1】:

试试这个:

{{ Form::open( array('route' => array('data.destroy', $entry[0]->id) ) ) }}

来自文档: http://laravel.com/docs/html#opening-a-form

【讨论】:

  • 工作...我以为我试过了。好吧,从角度来看,这不是一个好问题。感谢您的帮助
猜你喜欢
  • 2013-07-14
  • 1970-01-01
  • 2013-10-12
  • 1970-01-01
  • 2012-11-30
  • 2014-02-02
  • 2016-10-27
  • 1970-01-01
  • 2013-11-14
相关资源
最近更新 更多