1

I have this route:

Route::resource('riskfields', RiskfieldsController::class)->except('show');

Within the RiskfieldController/edit I'm calling the edit view as:

public function edit(Riskfield $riskField)
{
    return view('riskfields.edit', [
        'riskField' => $riskField
    ]);
}

where Riskfield is the model.

So, inside edit.blade.php I have:

{{ Form::open(['route' => ['riskfields.update', $riskField->id], 'method' => 'put', 'autocomplete' => 'off']) }}

when I access to this endpoint: /admin/riskfields/1/edit

I get:

Missing required parameter for [Route: riskfields.update] [URI: admin/riskfields/{riskfield}] [Missing parameter: riskfield]. (View: /var/www/html/resources/views/riskfields/edit.blade.php)

The problem's that I have inject the model, so I don't know what's happening there.

This is the update method:

public function update(Riskfield $riskField, Request $request): RedirectResponse

Someone could help?

UPDATE:

dd ouput:

enter image description here

8
  • if you dd riskfield object in the controller do youget the expected variable? Commented Jan 28, 2022 at 14:23
  • 1
    @MátyásGrőger check my update, seems I'm getting the model Commented Jan 28, 2022 at 14:26
  • could you check your rendered form with inspector and make a screenshot about that? The actual html form that this code renders. Thanks Commented Jan 28, 2022 at 14:32
  • @MátyásGrőger how can I inspect the edit form? If I open the page /admin/riskfields/1/edit I get the error above Commented Jan 28, 2022 at 14:34
  • ahh right. Well for me personally I have never used the Form syntax. I prefer to write the form myself in the view, there fore I am not sure what it renders. But the porblem is that when you define the route 'route' => ['riskfields.update', $riskField->id], it fails to render the id correctly Commented Jan 28, 2022 at 14:42

1 Answer 1

1

This problem stopped me for half an hour, but I hope my answer will help someone. Essentially I have to change this:

public function edit(Riskfield $riskField)

into:

public function edit(Riskfield $riskfield)

The parameter must have the same name convention defined within the route, so I've executed php artisan route:list and it was admin/riskfields/{riskfield}

Hope to help someone.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.