Borja Marco
Borja Marco

Reputation: 54

Laravel 5: Add value to fields in Form model

Hello I have a form in laravel opened in model form

{!! Form::model($issue, ['url' => 'calidad/issues/' . $issue->id, 'method' => 'PUT']) !!}

In the form i have some fields stored in a table as $key (name of the field) and $value (value of the field).

I can get the fields values with:

$issue->source()->get()

and this return a collection with the rows.

So my question is, how can i put this values in the form in a simple way.

Upvotes: 0

Views: 308

Answers (1)

Borja Marco
Borja Marco

Reputation: 54

I have a temporary solution with Blade + JQuery + php

In the controller y get the fields and i put them into an array

    $input = $issue->source()->get()->lists('value','key');

And I filled the fields with this:

@foreach($input as $key => $value)
    $("#{!!$key!!}").val("{!!$value!!}");
@endforeach

I cant think in anything else but this works.

Upvotes: 1

Related Questions