Andi Giga
Andi Giga

Reputation: 4172

Laravel/Blade Form PUT Method, dd(Input::all());

Hi I send a form in my contact.blade.php. I read in order to use the PUT method you have to create a hidden input field which contains the method.

      @if($do == 'edit')
        {{ Form::model($contact, array('method' => 'PUT', 'route' => array('contact.update', $contact->id), 'id' => $do=='edit' ? $do.$contact->id : $do.$contact_type_id, 'form_id' => $do=='edit' ? $do.$contact->id : $do.$contact_type_id)) }}
        {{ Form::hidden('_method', 'PUT') }}
      @endif
        ....
        {{ Form::submit('speichern', array('class' => 'btn btn-primary')) }}
        </div>
      {{ Form::close() }}

The route:

Route::put('/contact/{id}', array(
    'uses'      => 'ContactController@update',
    'as'        => 'contact.update'
));

The Controller:

public function update($id)
{
    dd(Input::all());
    // //get user account data
    // $user = User::find( Auth::id() );
    // // validate input
    // $v = Contact::dataValidation( Input::all() );
    return Redirect::Route('user.edit', 1)->withSuccess("<em>Hans</em> wurde gespeichert.");

Q1: As soon as I call dd(Input::all()); I don't get redirected any more, instead I see a json with my form values.

Q2: I'm just debugging this so I didn't program it. So my second question is: From my understanding dd(Input::all()); gets all my form data. So don't I need to store it anyways somewhere?

Upvotes: 1

Views: 2738

Answers (2)

mininoz
mininoz

Reputation: 5958

Question 1 when you use DD, it will show the data and stop at that line.

DD

Dump the given variable and end execution of the script.

more information you can read it here DD in DD session.

Question 2 I'am not sure about 2nd question but if you want to get value from all input you could us Input::all(); more information All input in Getting All Input For The Request session

Upvotes: 0

Chris
Chris

Reputation: 58242

Q1: dd() terminates the script, hence why you are not getting redirected. It's used as a tool to essentially break and examine what is going on.

http://laravel.com/docs/4.2/helpers

Q2: You will still need a model to feed the Input::all data into. Input::all simply fetches the submitted data, it doesn't do anything with it. It ultimately depends on your use case, sometimes you may want to email the data, but obviously most times you would what to store it against your persistence layer (read database / datastore)

Upvotes: 1

Related Questions