Monday, March 20, 2017

Edit form and showing current image in Laravel blade

I'm having form where I add some data to database. I want to make this same form to be populated with current data when I load page and to be able to change/update it.

So far everything works just fine except the part with image. It is showing blank page and the error is

Illegal string offset 'name'

this is the form

@foreach($preferences as $settings) 
      
    <div class="form-group">
        <label for="title" class="control-block">Title:</label>
        
    </div>

    <div class="form-group">
        <label for="title" class="control-block">Logo:</label>          
        
    </div>
    <div class="form-group">
        <label for="title" class="control-block">Logo (alt):</label>
        
    </div>              
    <hr />

    <button type="submit" class="btn btn-primary">Save Changes</button>


@endif

And simple controller function to display them

public function preferences() {

    $preferences = Preferences::all();
    return View::make('preferences', [
        'preferences' => $preferences
    ]);         
}

Why get illegal string offset 'name' when I don't even trying to show 'name'? And how can I populate current image on form when is opened so if user don't change it to not remove it from database?



via Jason Paddle

Advertisement