dongzhi1822 2017-08-13 15:57
浏览 30
已采纳

缺少[Route:ticket.edit] [URI:ticket_ads / edit / {ad}]所需的参数

I am trying to edit a record in a table. I have created a route and the form, but I can't get past this error. I have figured out the problem but I can't find a fix. Am I correct in thinking that the edit.blade.php file needs the $ad->id passing?

The $ad->id is an ID of a specific add in a List View. The list view has all the tickets displayed from a table, and the below link is meant to edit that one item.

The edit route is accessed using following code:

<a href="{{ route('ticket.edit', $ad->id) }}">Edit</a>

I have one route that is supposed to open up the edit view form:

Route::get('/ticket_ads/edit/{ad}', 'TicketAdsController@editTicketAdForm')->name('ticket.edit');

The above route points to this in the controller:

  public function editTicketAdForm($id)
  {
      //$ad = DB::table('ticket_ads')->where('id', $id)->value('id');
      return view('Ads.edit')->with('id', $id);
  }

This is the view called by the above function:

@extends('Shared.Layouts.MasterWithoutMenus')

@section('title')
Edit a ticket ad
@stop

@section('content')
<div class="container">
  <div class="row">
    <div class="col-md-8 col-md-offset-2">
      <div class="panel panel-default">
        <div class="panel-heading"><h2>Edit your ticket ad</h2></div>   <br/>

        @if ($errors->any())
            <div class="alert alert-danger">
                <ul>
                    @foreach ($errors->all() as $error)
                        <li>{{ $error }}</li>
                    @endforeach
                </ul>
            </div>
        @endif

        {{ Form::open(array('route' => 'ticket.edit', $id = 'id')) }}

        <div class="form-group">
            {{ Form::label('title', 'Title') }}
            {{ Form::text('title', Input::old('title'), array('class' => 'form-control')) }}
        </div>

        <div class="form-group">
            {{ Form::label('comment', 'Comment') }}
            {{ Form::text('comment', Input::old('comment'), array('class' => 'form-control')) }}
        </div>

        {{ Form::submit('Submit', array('class' => 'btn btn-primary')) }}

        {{ Form::close() }}
      </div>
    </div>
  </div>
 </div>
@endsection

This is the line that throws the error

{{ Form::open(array('route' => 'ticket.edit', $id = 'id')) }}

The ID displays normally in the URL as ticket_ads/edit/7 for example.

How do I get past this?

  • 写回答

2条回答 默认 最新

  • douzhuang2016 2017-08-13 18:26
    关注

    Change this line:

    {{ Form::open(array('route' => 'ticket.edit', $id = 'id')) }}
    

    to this:

    {{Form::open(array('route' => array('ticket.edit', $id)))}}
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题