Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

andreasnovian's avatar

The GET method is not supported for route activities/salesorder/store. Supported methods: POST.

When i submit the form, error appears "The GET Method is not supported for route activities/salesorder/store" even though the method I use already uses post.

This my code: route

Route::get('/activities/salesorder', [ActivitiesController::class, 'salesorder'])->name('activities.salesorder');
        Route::get('/activities/salesorder/add', [ActivitiesController::class, 'createsalesorder'])->name('activities.createsalesorder');
        Route::post('/activities/salesorder/store', [ActivitiesController::class, 'storesalesorder'])->name('activities.storesalesorder');

Controller

public function createsalesorder()
    {
        $work_unit = WorkUnit::get();
        $kbli = Kblicode::get();
        return view('activities.createsalesorder',compact('work_unit','kbli'));
    }

    public function storesalesorder(Request $request)
    {
        $validator = Validator::make(
            $request->all(),
            [
                'quotation_no' => 'required',
                'sales_order_no' => 'required',
                'company_name' => 'required',
                'name' => 'required',
                'date' => 'required',
                'kbli' => 'required',
                'email' => 'required',
                'telephone' => 'required',
                'unit' => 'required',
                'po_no' => 'required',
                'address' => 'required',
                'npwp' => 'required',
                'tax_address' => 'required',
                'scope_of_work_no' => 'required',
                'reference_number' => 'required',
                'work_unit' => 'required',
                'fax' => 'required',
                'radio-information'=>'required',
                'confirmation' => 'required',
                'special_requirement' => 'required',
                'delivery_statement' => 'required',
                'term_of_payment' => 'required',
                'dod' => 'required',
                'image' => 'nullable',
                'sample_reference' => 'required',
                'assy_type' => 'required',
                'qc_statement' => 'required',
                'packing_type' => 'required',
                'discount' => 'required',
                'discount_percent' => 'required',
                'total_amount' => 'required',
                'down_of_payment' => 'required',
                'down_of_payment_percent' => 'required',
                'shippingpoint'=>'required',
                'salesman' => 'required',
            ]
        );
        if ($validator->fails()) {
            return redirect()->route('activities.createsalesorder')->withErrors($validator)->withInput();
        }

        $salesorder = new SalesOrder();
        $salesorder->quotation_no = $request->quotation_no;
        $salesorder->sales_order_no = $request->sales_order_no;
        $salesorder->company_name = $request->company_name;
        $salesorder->name = $request->name;
        $salesorder->date = $request->date;
        $salesorder->kbli = $request->kbli;
        $salesorder->email = $request->email;
        $salesorder->telephone = $request->telephone;
        $salesorder->unit = $request->unit;
        $salesorder->po_no = $request->po_no;
        $salesorder->address = $request->address;
        $salesorder->npwp = $request->npwp;
        $salesorder->tax_address = $request->tax_address;
        $salesorder->scope_of_work_no = $request->scope_of_work_no;
        $salesorder->reference_number = $request->reference_number;
        $salesorder->work_unit = $request->work_unit;
        $salesorder->fax = $request->fax;
        $salesorder->radio_information=$request->radio_information;
        $salesorder->confirmation = $request->confirmation;
        $salesorder->special_requirement = $request->special_requirement;
        $salesorder->delivery_statement = $request->delivery_statement;
        $salesorder->term_of_payment = $request->term_of_payment;
        $salesorder->dod = $request->dod;
        $salesorder->image = $request->image;
        $salesorder->sample_reference = $request->sample_reference;
        $salesorder->assy_type = $request->assy_type;
        $salesorder->qc_statement = $request->qc_statement;
        $salesorder->packing_type = $request->packing_type;
        $salesorder->discount = $request->discount;
        $salesorder->discount_percent = $request->discount_percent;
        $salesorder->total_amount = $request->total_amount;
        $salesorder->down_of_payment = $request->down_of_payment;
        $salesorder->down_of_payment_percent = $request->down_of_payment_percent;
        $salesorder->shippingpoint = $request->shippingpoint;
        $salesorder->salesman = $request->salesman;
        $salesorder->save();

        return redirect()->route('activities.salesorder')->with('success', 'Sales Order Added');
    }

createsalesorder.blade

<form action="{{ route('activities.storesalesorder') }}" method="POST" enctype="multipart/form-data"
                    onsubmit="return validateForm();">
                    @csrf
                    <div class="card-header">
                        <h3 class="card-title">SO Add Form</h3>
                        <br>
                        <label for="InputHtml">Import</label>
                        <input type="file" name="html" class="form-control-file" id="InputHtml" accept=".htm">

                    </div>
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="row mb-0">
                                    <div class="col-sm-3">
                                        <p style="font-size: 15px" class="m-0">Quotation No.</p>
                                    </div>
                                    <div class="col-sm-2">
                                        <p style="font-size: 15px" class="m-0">Date</p>
                                    </div>
                                    <div class="col-sm-1">
                                        <p style="font-size: 15px" class="m-0">Unit</p>
                                    </div>
                                    <div class="col-sm-2">
                                        <p style="font-size: 15px" class="m-0">No Po.</p>
                                    </div>
                                    <div class="col-sm-2">
                                        <p style="font-size: 15px" class="m-0">SOW No.</p>
                                    </div>
                                    <div class="col-sm-2">
                                        <p style="font-size: 15px" class="m-0">Confirmation</p>
                                    </div>
                                </div>
                                <div class="row mb-1">
                                    <div class="col-sm-3">
                                        <input type="text" name="quotation_no" class="form-control" id="InputProcess"
                                            placeholder="Input Quotation No."  required>
                                    </div>
                                    <div class="col-sm-2">
                                        <input type="date" name="date" class="form-control" id="InputProcess"
                                            placeholder="Date"  required>
                                    </div>
                                    <div class="col-sm-1">
                                        <select class="form-control select2" name="work_unit" id="work_unit"
                                            style="width: 100%;">
                                            <option selected="selected" required disabled selected>
                                            </option>
                                            @foreach ($work_unit as $wu)
                                                <option value="{{ $wu->work_unit }}">
                                                    {{ $wu->work_unit }}--{{ $wu->information }}</option>
                                            @endforeach
                                        </select>
                                        @error('work_unit')
                                            <small class="text-danger">{{ $message }}</small>
                                        @enderror
                                    </div>
                                    <div class="col-sm-2">
                                        <input type="text" name="po_no" class="form-control" id="InputProcess"
                                            placeholder="Input No Po." value="" required>
                                    </div>
                                    <div class="col-sm-2">
                                        <input type="text" name="scope_of_work_no" class="form-control" id="InputProcess"
                                            placeholder="Input SOW No." value="" required>
                                    </div>
                                    <div class="col-sm-2">
                                        <input type="radio" id="meet" name="confirmation" value="meet">
                                        <label for="meet"class="radio-label">Meet</label>
                                    </div>
                                </div>
                                <div class="row mb-1">
                                    <div class="col-sm-3">
                                        <p style="font-size: 15px" class="m-0">So No.</p>
                                    </div>
                                    <div class="col-sm-2">
                                        <p style="font-size: 15px" class="m-0">KBLI</p>
                                    </div>
                                    <div class="col-sm-3">
                                        <p style="font-size: 15px" class="m-0">Address</p>
                                    </div>
                                    <div class="col-sm-3">
                                        <p style="font-size: 15px" class="m-0">Reference Number</p>
                                    </div>
                                </div>
                                <div class="row mb-1">
                                    <div class="col-sm-3">
                                        <input type="text" name="sales_order_no" class="form-control"
                                            id="InputProcess" placeholder=" Input So No." value="" required>
                                    </div>
                                    <div class="col-sm-2">
                                        <select class="form-control select2" name="kbli" id="kbli"
                                            style="width: 100%;">
                                            <option selected="selected" required disabled selected>-- Select a KBLI Code --
                                            </option>
                                            @foreach ($kbli as $k)
                                                <option value="{{ $k->kbli_code }}">
                                                    {{ $k->kbli_code }}</option>
                                            @endforeach
                                        </select>
                                        @error('kbli')
                                            <small class="text-danger">{{ $message }}</small>
                                        @enderror
                                    </div>
                                    <div class="col-sm-3">
                                        <input type="text" name="address" class="form-control" id="InputProcess"
                                            placeholder="Input Address" value="" required>
                                    </div>
                                    <div class="col-sm-2">
                                        <input type="text" name="reference_number" class="form-control"
                                            id="InputProcess" placeholder="Input Reference Number" value=""
                                            required>
                                    </div>
                                    <div class="col-sm-2">
                                        <input type="radio" id="byphone" name="confirmation" value="byphone">
                                        <label for="byphone"class="radio-label">by Phone</label>
                                    </div>
                                </div>

                                <div class="row mb-1">
                                    <div class="col-sm-3">
                                        <p style="font-size: 15px" class="m-0">Company Name</p>
                                    </div>
                                    <div class="col-sm-2">
                                        <p style="font-size: 15px" class="m-0">Email</p>
                                    </div>
                                    <div class="col-sm-3">
                                        <p style="font-size: 15px" class="m-0">NPWP</p>
                                    </div>
                                    <div class="col-sm-2">
                                        <p style="font-size: 15px" class="m-0">Telepon</p>
                                    </div>
                                    <div class="col-sm-2">

                                    </div>
                                </div>

                                <div class="row mb-1">
                                    <div class="col-sm-3">
                                        <input type="text" name="company_name" class="form-control" id="InputProcess"
                                            placeholder="Input Company Name" value="" required>
                                    </div>
                                    <div class="col-sm-2">
                                        <input type="email" name="email" class="form-control" id="InputProcess"
                                            placeholder="Input Email" value="" required>
                                    </div>
                                    <div class="col-sm-3">
                                        <input id="InputNPWP" type="text" name="npwp" class="form-control"
                                            id="InputProcess" placeholder="__.___.___._-___.___" value="" required>
                                    </div>
                                    <div class="col-sm-2">
                                        <input type="text" name="telephone" class="form-control" id="InputProcess"
                                            placeholder="Input Telepon" value="" required>
                                    </div>
                                    <div class="col-sm-2">
                                        <input type="radio" id="email" name="confirmation" value="email">
                                        <label for="email"class="radio-label">Email</label>
                                    </div>
                                </div>

                                <div class="row mb-1">
                                    <div class="col-sm-3">
                                        <p style="font-size: 15px" class="m-0">Name</p>
                                    </div>
                                    <div class="col-sm-2">

                                    </div>
                                    <div class="col-sm-3">
                                        <p style="font-size: 15px" class="m-0">Tax Address</p>
                                    </div>
                                    <div class="col-sm-2">
                                        <p style="font-size: 15px" class="m-0">Fax</p>
                                    </div>
                                </div>
                                <div class="row mb-1">
                                    <div class="col-sm-3">
                                        <input type="text" name="name" class="form-control" id="InputProcess"
                                            placeholder="Input Name" value="" required>
                                    </div>
                                    <div class="col-sm-2">

                                    </div>
                                    <div class="col-sm-3">
                                        <input type="text" name="tax_address" class="form-control" id="InputProcess"
                                            placeholder="Input Tax Address" value="" required>
                                    </div>
                                    <div class="col-sm-2">
                                        <input type="text" name="fax" class="form-control" id="InputProcess"
                                            placeholder="Input Fax" value="" required>
                                    </div>
                                    <div class="col-sm-2">
                                        <input type="radio" id="fax" name="confirmation" value="fax">
                                        <label for="fax"class="radio-label">Fax</label>
                                    </div>
                                </div>

                                <div class="row mb-1">
                                    <div class="col-sm-10">
                                    </div>
                                    <div class="col-sm-2 mt-3 ">
                                        <input type="radio" id="pilihan1" name="confirmation" value="nilai1">
                                        <label for="pilihan1"class="radio-label">Note</label>
                                    </div>
                                </div>

                                <div class="row mb-0">
                                    <div class="col-sm-8 radio-border">
                                        <input type="radio" id="new" name="radio-information" value="new">
                                        <label for="new"class="radio-label1">New</label>

                                        <input type="radio" id="repeat" name="radio-information" value="repeat">
                                        <label for="repeat"class="radio-label1">Repeat</label>

                                        <input type="radio" id="prototype" name="radio-information" value="prototype">
                                        <label for="prototype"class="radio-label1">Prototype</label>

                                        <input type="radio" id="repair" name="radio-information" value="repair">
                                        <label for="repair"class="radio-label1">Repair</label>

                                        <input type="radio" id="resharpening" name="radio-information"
                                            value="resharpening">
                                        <label for="resharpening"class="radio-label1">Resharpening</label>

                                        <input type="radio" id="harden" name="radio-information" value="harden">
                                        <label for="harden"class="radio-label1">Harden</label>

                                        <input type="radio" id="painting" name="radio-information" value="painting">
                                        <label for="painting"class="radio-label1">Painting</label>

                                        <input type="radio" id="others" name="radio-information" value="others">
                                        <label for="others"class="radio-label1">Others</label>
                                    </div>

                                </div>
                            </div>
                            <div class="col md-10">

                            </div>

                        </div>
                    </div>
                    <div class="row">
                        <div class="col-12">
                            <div class="card-body">
                                <button id="tambahbaris" class="btn btn-primary">Add</button>
                                <table id="tableso" class="table table-head-fixed text-nowrap">
                                    <thead>
                                        <tr>
                                            <th>Item</th>
                                            <th>Item Description</th>
                                            <th>Qty</th>
                                            <th>Unit</th>
                                            <th>Unit Price</th>
                                            <th>Desc %</th>
                                            <th>Tax</th>
                                            <th>No. Order</th>
                                            <th>Spesification</th>
                                            <th>Amount</th>
                                            <th>KBLI</th>
                                            <th>Shipped</th>
                                            <th>Dept</th>
                                            <th>Quote No</th>
                                            <th>Action</th>
                                        </tr>
                                    </thead>
                                    <tr>
                                        <td><input type="text" name="item" class="form-control"
                                                style="width: 100px"></td>
                                        <td>
                                            <textarea type="text" name="itemdesc" class="form-control" style="width: 250px; height:40px"></textarea>
                                        </td>
                                        <td><input type="text" name="qty" class="form-control"></td>
                                        <td><input type="text" name="unit" class="form-control"></td>
                                        <td><input type="text" name="unitprice" class="form-control"
                                                style="width: 150px"></td>
                                        <td><input type="text" name="descount" class="form-control"></td>
                                        <td><input type="text" name="tax" class="form-control"
                                                style="width: 40px"></td>
                                        <td><input type="text" name="noorder" class="form-control"
                                                style="width: 110px"></td>
                                        <td><input type="text" name="spec" class="form-control"
                                                style="width:120px"></td>
                                        <td><input type="text" name="amount" class="form-control"
                                                style="width: 150px"></td>
                                        <td><input type="text" name="kbli" class="form-control"
                                                style="width: 70px"></td>
                                        <td><input type="text" name="shipped" class="form-control"></td>
                                        <td><input type="text" name="dept" class="form-control"
                                                style="width: 60px"></td>
                                        <td><input type="text" name="qouteno"
                                                class="form-control"style="width: 110px"></td>
                                        <td></td>
                                    </tr>
                                </table>
                            </div>
                            <!-- /.card-body -->
                        </div>
                        <!-- /.card -->
                    </div>

                    <!-- /.row (main row) -->


                    <div class="content-header">
                        <div class="container-fluid">
                            <div class="row">
                                {{-- Special Requirement --}}
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <p style="font-size: 15px" class="m-0">Special Requirement</p>
                                        <textarea type="text" name="requirement" class="form-control" id="requirement"
                                            placeholder="Input Special Requirement" value="" required></textarea>
                                        <p style="font-size: 15px" class="m-0 mt-3">Sample Reference</p>
                                        <div class="col-sm-7 radio-border">
                                            <input type="radio" id="photo" name="samplereference" value="photo">
                                            <label for="photo"class="radio-label">Photo</label>
                                            <input type="radio" id="pilihan1" name="samplereference"
                                                value="2ddrawing">
                                            <label for="2ddrawing"class="radio-label">2D Drawing</label><br>
                                            <input type="radio" id="3ddrawing" name="samplereference"
                                                value="3ddrawing">
                                            <label for="3ddrawing"class="radio-label">3D Drawing</label>
                                            <input type="radio" id="sample" name="samplereference" value="sample">
                                            <label for="sample"class="radio-label">Sample</label><br>
                                            <input type="radio" id="none" name="samplereference" value="none">
                                            <label for="none"class="radio-label">None</label>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-2">
                                    <div class="form-group">
                                        <p style="font-size: 15px" class="m-0">Delivery Statement</p>
                                        <div style="font-size: 15px;">
                                            <input type="radio" id="priceincludetransport" name="deliverystatement"
                                                value="priceincludetransport">
                                            <label for="priceincludetransport">Price Include Transport</label><br>
                                            <input type="radio" id="priceexcludetransport" name="deliverystatement"
                                                value="priceexcludetransport">
                                            <label for="priceexcludetransport">Price Exclude Transport</label>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-2">
                                    <div class="form-group">
                                        <p style="font-size: 15px" class="m-0">Term of Payment</p>
                                        <div style="font-size: 15px;">
                                            <input type="radio" id="cod" name="termofpayment" value="COD">
                                            <label for="cod" style="margin-right: 20px">COD</label>
                                            <input type="radio" id="cbd" name="termofpayment" value="CBD">
                                            <label for="cbd">CBD</label><br>
                                            <input type="radio" id="net30" name="termofpayment" value="NET 30">
                                            <label for="net30">NET 30</label>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-2">
                                    <div class="form-group">
                                        <p style="font-size: 15px" class="m-0">DOD</p>
                                        <input type="date" name="dod" class="form-control" id="InputProcess"
                                            placeholder="Name Order" value="" required>
                                    </div>
                                </div>
                                <div class="col-md-2">
                                    <div class="form-group">
                                        <label for="InputImage">Upload Image</label>
                                        <input type="file" name="image" class="form-control-file" id="InputImage"
                                            accept="image/*">
                                        <img id="imagePreview" class="mt-3" src="#" alt=""
                                            style="max-width: 100%; max-height: 200px; display: block; margin: 0 auto;">
                                    </div>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-2">
                                    {{-- Assy Type --}}
                                    <div class="form-group">
                                        <p style="font-size: 15px" class="m-0">Assy Type</p>
                                        <div style="font-size: 15px;">
                                            <input type="radio" id="assyinatmi" name="assytype" value="nilai1">
                                            <label for="assyinatmi"class="radio-label">Assy in ATMI</label><br>
                                            <input type="radio" id="assyonshipping" name="assytype" value="nilai1">
                                            <label for="assyonshipping">Assy on Shipping Location</label>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-2">
                                    <div class="form-group">
                                        <p style="font-size: 15px" class="m-0">QC Statement</p>
                                        <div style="font-size: 15px;">
                                            <input type="radio" id="qcsheet" name="qcstatement" value="QC Sheet">
                                            <label for="qcsheet">QC Sheet</label><br>
                                            <input type="radio" id="assytestreport" name="qcstatement"
                                                value="Assy Test Report">
                                            <label for="assytestreport">Assy Test Report</label>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-2">
                                    <div class="form-group">
                                        <p style="font-size: 15px" class="m-0">Packing Type</p>
                                        <div style="font-size: 15px;">
                                            <input type="radio" id="cartonpacking" name="packingtype"
                                                value="cartonpacking">
                                            <label for="cartonpacking">Carton Packing</label><br>
                                            <input type="radio" id="woodpacking" name="packingtype"
                                                value="woodpacking">
                                            <label for="woodpacking">Wood Packing</label><br>
                                            <input type="radio" id="specialpacking" name="packingtype"
                                                value="specialpacking">
                                            <label for="specialpacking">Special Packing</label>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-2">
                                    <div class="form-group">
                                        <div style="font-size: 15px; margin-top:10%;">
                                            <input type="radio" id="inlcudetax" name="tax" value="inlcudetax">
                                            <label for="inlcudetax"class="radio-label">Include Tax</label><br>
                                            <input type="radio" id="excludetax" name="tax" value="excludetax">
                                            <label for="excludetax"class="radio-label">Exclude Tax</label>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-2">
                                    <p style="font-size: 15px" class="m-0">Discount</p>
                                    <div class="row">
                                        <div class="col-md-9">
                                            <input type="text" name="discount_percent" class="form-control"
                                                id="InputProcess" placeholder="Discount (%)" value="" required>
                                        </div>
                                        <div class="col-md-2">
                                            <div class="vertical-center">
                                                %
                                            </div>
                                        </div>
                                    </div>

                                    <p style="font-size: 15px" class="m-0 mt-1">Total Amount</p>


                                    <p style="font-size: 15px" class="m-0 mt-5">Down of Payment</p>
                                    <div class="row">
                                        <div class="col-md-9">
                                            <input type="text" name="down_of_payment_percent" class="form-control"
                                                id="InputProcess" placeholder="DP (%)" value="" required>
                                        </div>
                                        <div class="col-md-2">
                                            <div class="vertical-center">
                                                %
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <div class="col-md-2">
                                    <div class="row" style="margin-top: 11%">
                                        <div class="col-md-2">
                                            <div class="vertical-center" style="margin-top: 16%">
                                                Rp
                                            </div>
                                            <div class="vertical-center" style="margin-top: 115px">
                                                Rp
                                            </div>
                                        </div>
                                        <div class="col-md-9">
                                            <input type="text" name="discount" class="form-control" id="InputProcess"
                                                placeholder="" value="" required>
                                            <input type="text" name="total_amount" class="form-control"
                                                id="InputProcess" placeholder="" value="" required
                                                style="margin-top: 17%">
                                            <input type="text" name="down_of_payment" class="form-control"
                                                id="InputProcess" placeholder="" value="" required
                                                style="margin-top: 27%">
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-2">
                                    <div class="form-group">
                                        <p style="font-size: 15px" class="m-0">Shipping Point</p>
                                        <div style="font-size: 15px;">
                                            <input type="radio" id="local" name="shippingpoint" value="local">
                                            <label for="local"class="radio-label">Local</label><br>
                                            <input type="radio" id="export" name="shippingpoint" value="export">
                                            <label for="export"class="radio-label">Export</label>
                                        </div>
                                    </div>
                                </div>

                                <div class="col-md-6">
                                    <div class="form-group">
                                        <p style="font-size: 15px" class="m-0">Address</p>
                                        <div>
                                            <textarea type="text" name="address" class="form-control" id="InputProcess" placeholder="Input Address"
                                                value="" required></textarea>
                                        </div>
                                    </div>
                                </div>

                                <div class="col-md-2">
                                    <div class="form-group">
                                        <p style="font-size: 15px" class="m-0">Salesman</p>
                                        <div>
                                            <input type="text" name="salesman" class="form-control" id="InputProcess"
                                                placeholder="Input Salesman" value="" required>
                                        </div>
                                    </div>
                                </div>
                            </div>

                        </div>

                    </div>
                    <!-- /.card-body -->
                    <div class="card-footer">
                        <button type="submit" class="btn btn-primary">Add SO</button>
                    </div>
                </form>
0 likes
15 replies
andreasnovian's avatar

@tangtang <form action="{{ route('activities.storesalesorder') }}" method="POST" enctype="multipart/form-data"onsubmit="return validateForm();">

tangtang's avatar

@andreasnovian

I don't really know how you handle the validation back.

but first I just realize that some typo in your field validation

// 'radio-information'=>'required', // this is your current code
// replace with this code
'radio_information'=>'required',
// you typo the underline to hyphen

I'm guessing this is the problem

return redirect()->route('activities.createsalesorder')->withErrors($validator)->withInput();

because if there something error detect from validation, this code will be execute. and the error come from this code (but not really one)

you must recheck your validateForm() too

ensure that the validateForm() javascript function does not interfere with the form submission or force a GET request. double-check your javascript code to ensure it is not causing any issues.

Tray2's avatar
Tray2
Best Answer
Level 73

You need to wrap your form elements in a form tag

<form action="<your route>" method="POST">
	@csrf
	<!-- Your form elements here -->
</form>
andreasnovian's avatar
<form action="{{ route('activities.storesalesorder') }}" method="POST" enctype="multipart/form-data"
                    onsubmit="return validateForm();">`
                    @csrf
<!--  form elements -->
<div class="card-footer">
                        <button type="submit" class="btn btn-primary">Add SO</button>
                    </div>
</form>
Tray2's avatar

@andreasnovian Good, make sure you have the correct method set for it, it should be post, and nothing else.

andreasnovian's avatar

@Tray2 I am sure that the method I used has been post. Is there another possibility that could be causing the error?

Tray2's avatar

@andreasnovian Nope, you are sending a GET request instead of a POST. If you form has method="POST". then you should be good, unless you use ajax to send the request to the server.

Snapey's avatar

If your form is posted correctly, yet there is a validation error, then you are redirecting to route('activities.createsalesorder') make sure that this is a GET route

2 likes
kokoshneta's avatar

@Snapey It is, according to the (unformatted) route definitions given in the question.

1 like
kokoshneta's avatar

First off, please edit the question to format your code properly – it’s very hard to read! You can make code blocks by adding three backticks (```) on a separate line above and below your code.

Secondly, there doesn’t seem to be a problem in the code you have shown us, but you’ve only shown some of the relevant code. Please also show us,

  • your ActivitiesController::salesorder() method
  • your JavaScript validateForm() function

And what is the purpose of the validateForm() function when you validate the form in your controller? If you’re using validateForm() to actually send the request to the store endpoint, then that is likely where you’re sending a GET request instead of a POST request.

Please or to participate in this conversation.