Support the ongoing development of Laravel.io →
posted 11 years ago
Blade Forms

Hi there. I'm trying to get a bit of simple routing done and it's not working as expected. I have the following route defined

Route::group(
    array(
        'prefix' => 'admin',
        'namespace' => 'Admin',
    ),
    function () {
        Route::group(
            array(
                'prefix' => 'nearest',
                'namespace' => 'Nearest'
            ),
            function () {
                Route::resource('dataset', 'DataSetController');
            }
        );
    }
);

If I visit the URL that I expect this resource to catch, it works fine (e.g. /admin/nearest/dataset). The problem is when I start using the route in a form. So, I have the following in a blade template:

{{ Form::open(array('route' => 'admin.nearest.dataset.show', 'method' => 'get') }}

When this is rendered to HTML though, instead of the form action being /admin/nearest/dataset it's actually:

<form method="GET" action="http://dev.niceroundhere.com/admin/nearest/dataset/%7Bdataset%7D" accept-charset="UTF-8">

Mysteriously, it's added {dataset} escaped to the action! Am I doing something insane? Have I missed something important out? Give that the .show method expects a url of /resource/{id}, is this what's happening? DO I need to write my own bespoke javascript to catch the form submit and that the id (from a <SELECT>) and paste it into the URL where {dataset} is? Is there anything that Laravel provides to achieve this before I write my own?

Last updated 3 years ago.
0

The action url seems ok for a "show" action (I think it makes no difference if the placeholder is named {dataset} rather than simply {id}).
What I do not understand is why you would have a form with a "show" action (normally, a form would have a "create" or "update" action).

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

c0ntax c0ntax Joined 11 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.