2 months ago

Forms, Query Strings, and Controller Parameters

Posted 2 months ago by grozavule

I have an HTML form that submits a GET request. Below is the Blade template for it:


    <div class="alert alert-danger">{{ $message }}</div>
    <div class="row">
        <p>Type a part number into the box and press "Generate Report" (Example:
            <a href="{{ route('', ['serial' => '90114-624']) }}"> 90114-624</a>).</p>
        <p>Printing is optimized for the Chrome browser.
            <a href="javascript:window.print()"><em class="fi-print"></em> Click here to print.</a></p>
        <p>To print select tubs type desired page numbers under print preview (Example: 1-3 or 1,2,3)</p>
    <div class="row">
        <form action="{{ route('', ['serial'])  }}" method="get">
            <label for="serial">Serial Number:</label>
            <input type="text" name="serial" value="{{ old('serial') or '' }}">
            <input type="submit" value="Generate" class="button postfix">

The route definition is as follows:

Route::get('/fabrication/weldtub/{serial}', '[email protected]')->name('');

When the form submits, I would like it to use this route instead of appending a query string the the URL. How can I do that? If this isn't the right way to make this work, please point me in the right direction.

Please sign in or create an account to participate in this conversation.