Skip to content

Form model binding not working in blade components #8

@aviqbaihaqy

Description

@aviqbaihaqy

Form model binding not working in blade components

Form model binding is not working when you create a form component:

@component('components.form', ['model' => $product ?? null, 'route' => 'products'])
  @component('components.form-group', ['name' => 'name', 'label' => 'Product name:'])
    {!! Form::text('name', null, ['class' => 'form-control']) !!}
  @endcomponent
@endcomponent

And components/form.blade.php looks like this:

{!! Form::model($model, ['method' => 'PATCH', 'route' => [$route . '.update', $model->id]]) !!}
  {!! $slot !!}
{!! Form::close() !!}

In this case the field values are not populating (the attributes are exist in the $model object). When I use Form::model() just where I make the fields, it's working fine. If I @include the form opener part, it's also working fine.

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions