Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes a bug where passed to route() causes errors #627

Merged
merged 2 commits into from
May 17, 2020

Conversation

ChrisThompsonTLDR
Copy link
Contributor

@ChrisThompsonTLDR ChrisThompsonTLDR commented Nov 13, 2019

This attempts to fix a bug with routes having an array with two values.

This bugfix was tested and works with the following.

Non-route model binding:

{{ Form::open(['route' => ['mytest', [$file->id]]]) }}

Another non-route model binding:

{{ Form::open(['route' => ['mytest', $file->id]]) }}

Multiple models into route model binding:

{{ Form::open(['route' => ['manage.files.delete', [$currentPodcast, $file]]]) }}

Single model into route model binding:

{{ Form::open(['route' => ['manage.podcast.delete', $currentPodcast]]) }}

This attempts to fix LaravelCollective#510 even though the example provided by @zsoltgyure isn't actually using route model binding.

This bugfix was tested and works with the following.

Non-route model binding:
```
{{ Form::open(['route' => ['mytest', [$file->id]]]) }}
```

Another non-route model binding:
```
{{ Form::open(['route' => ['mytest', $file->id]]) }}
```

Multiple models into route model binding:
```
{{ Form::open(['route' => ['manage.files.delete', [$currentPodcast, $file]]]) }}
```

Single model into route model binding:
```
{{ Form::open(['route' => ['manage.podcast.delete', $currentPodcast]]) }}
```
@zoltiecodes
Copy link

Hi. My issue is not about route model binding, it's about form model binding. If you try to use the Form::model() method in a custom blade component, the model attributes won't fill the form field values. In any other case the form model binding works. So this PR won't fix the issue.

@ChrisThompsonTLDR
Copy link
Contributor Author

Ah, sorry about that. I misread your issue title..

@zoltiecodes
Copy link

Ah, sorry about that. I misread your issue title..

No problem. 👍

@ChrisThompsonTLDR
Copy link
Contributor Author

@mlantz or @jasonmccreary any chance of getting this merged?

It's currently not possible to open a form that contains a route with multiple parameters.

{{ Form::open(['route' => ['manage.memberships.store', [$routeOrganization, $routeAccount]]]) }}

throws

ErrorException
Array to string conversion
Illuminate\View\Engines\CompilerEngine::handleViewException
vendor/laravel/framework/src/Illuminate/Routing/RouteUrlGenerator.php:199

@jasonmccreary
Copy link
Contributor

I have no power here... 😅

@ChrisThompsonTLDR ChrisThompsonTLDR changed the base branch from 6.0 to 6.x April 17, 2020 13:29
@mlantz mlantz merged commit 8d18ac6 into LaravelCollective:6.x May 17, 2020
mlantz added a commit that referenced this pull request May 19, 2020
redo pull request #627 with backwards compatibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants