Form model binding isn't working with section/include

Audiophile posted 11 months ago

Laravel 5.4, laravelcollective/html 5.4.8

Parent Blade template for creating/editing Entries:

(as you see, it includes specific form fields)



<div class="panel-body">

    {!! Form::model($entry, ['method' => $method, 'class' => 'form-horizontal', 'route' => [$route]]) !!}

        @foreach (['title', 'url', 'content', 'meta_tags', 'meta_description', 'is_active'] as $field)
            @include('entries.fields.' . $field)

    <div class="form-group">
        <div class="col-sm-offset-3 col-sm-6">
                {!! Form::submit('Добавить', ['class' => 'btn btn-default']) !!}

    {!! Form::close() !!}

Child template for creating Articles (with it's own fields set):


    Добавить статью / {{ config('site.site_name') }}

    @foreach ([
         ] as $field)

The problem is that when I don't redefine 'fields' setcion, the fields have values which the given $entry object contains, but once I've redefined it, the values autofilling stops working.

For example, I have enable_comments checkbox:

<div class="form-group">
    {!!   Form::label('is_active', 'Активна', ['class' => 'col-sm-3 control-label']) !!}

    <div class="col-sm-6">
        {!! Form::checkbox('is_active', null, null, ['class' => 'checkbox']) !!}

And it is always unchecked, while the $entry->enable_comments === true

I don't know why this is happening. How to resolve this problem?


Sign in to participate in this thread!

We'd like to thank these amazing companies for supporting us