V
V
Viktor Grachev2014-09-22 15:20:01
Laravel
Viktor Grachev, 2014-09-22 15:20:01

How to edit table rows in laravel 4 modal window?

Good afternoon! Can you please tell me how to create a modal window for editing a table row? I understand how to create a modal window with a form, but I can’t figure out how to transfer data from the table to the modal window, because I'm not good at javascript. Please tell me where to dig or where to read?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel, 2014-10-02
@PaulTMatik

Move the form to a separate view.
For example: app/views/form.blade.php

{{ Form::model($model, ['method'=>'PUT']) }}
    {{ Form::text('column_name') }}
   ....
{{ Form::close() }}

(only in the code you will define form elements, in the value of the name attribute, enter the name of the columns of your table).
Define a method that will return this view on ajax request
For example:
public function getForm()
{
    $model = Model::find(Input::get('id'));
    return View::make('form', ['model'=>$model]);
}

and already substitute this answer in your modal window.
It is better to read about forms here Laravel API Illuminate\Html\FormBuilder

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question