mercredi 26 décembre 2018

Laravel - Form data not getting passed even when using name attribute

I have a comment form what i'm trying to submit with the comment and ticket_id but for some reason the data isn't getting passed with the request. I'm using the name="" attribute on the inputs. i have tried dumping the request info dd($request->all()) and the only thing it returns is the csrf_token and the files=>null.

Form:

<form method="POST" action="">
       
       <input type="hidden" style="display: none;" name="rma_ticket_id" value="" disabled>
       <div class="js-summernote" name="comment"></div>
       <div class="mt-3 clearfix">
            <button type="submit" class="btn btn-primary float-right">
              <i class="fa fa-plus mr-1"></i> Post Comment
            </button>

           @if ($rma->status->name != "Closed")
              <button type="button" class="btn btn-danger float-left">
                   <i class="fa fa-times mr-1"></i> Close
           </button>
           @endif

        </div>
</form>

Controller:

/**
     * Post comment and notify the customer.
     *
     * @param Request $request
     * @return \Illuminate\Http\RedirectResponse
     */
    public function postComment(Request $request)
    {
        try {

            dd($request->all());

            $comment = RmaComments::create([
                'user_id'       => Auth::user()->id,
                'rma_ticket_id' => $request->input('rma_ticket_id'),
                'name'          => Auth::user()->first_name.''.Auth::user()->last_name,
                'comment'       => $request->input('comment'),
            ]);

            // TODO - add function to notify customer when message is posted.

            return redirect()->back()->with('success', 'Your comment has be submitted to the customer.');

        } catch (\Exception $e)
        {
            // return redirect()->back()->with('danger', 'There was a problem trying to post your comment.');
            return redirect()->back()->with('danger', $e->getMessage());
        }
    }

Route:

Route::post('/returns/postComment', 'Backend\RmaController@postComment')->name('admin.returns.postComment');



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire