ID does not pass from view to controller

Posted 2 months ago by WallyJ

Relationships are set in the model

Form in view:

{!! Form::open(['route' => ['contactnotes.store', $contact->id]]) !!} 
     {{ csrf_field() }}
          <div class="form-group">
               {{Form::textarea('contactnotetext', null, array('placeholder' => 'Your note here', 'class' => 'form-control', 'rows' => '3'))}}
          <div class="form-group">
               {{Form::submit('Add Note', array('class' => 'btn btn-primary'))}}


public function store(Contact $contact, Request $request)
        $contactnote = new Contactnote;
        $contactnote->contact_id = $contact->id;
        $contactnote->contactnotetext = $request->contactnotetext;
        return $contactnote;

I don't understand why the id is not being passed. When I submit the form I get:

"contact_id": null,
"contactnotetext": "adsf",
"contact": []

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

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.