netojose / laravel-bootstrap-4-forms

Bootstrap 4 forms for Laravel 5/6/7/8
MIT License
183 stars 58 forks source link

patch() not working correctly #72

Closed ataylor32 closed 5 years ago

ataylor32 commented 5 years ago

Here is my form:

{!! Form::open()->route('posts.update', [$post->id])->fill($post)->patch() !!}
{!! Form::text('title', 'Title')->attrs(['maxlength' => '255'])->required() !!}
{!! Form::textarea('body', 'Body')->attrs(['class' => 'wysiwyg'])->required() !!}
<input type="hidden" name="allow_comments" value="0">
{!! Form::checkbox('allow_comments', 'Allow comments?', '1')->wrapperAttrs(['class' => 'wrapper-allow_comments']) !!}
{!! Form::submit('Update Post') !!}
{!! Form::close() !!}

The <form> tag that gets generated by the above code starts with <form method="patch", so the browser doesn't handle it correctly. Because of that, I need to remove ->patch() and add this to my form:

<input type="hidden" name="_method" value="patch">
netojose commented 5 years ago

Fixed on 3.0.3 version, thanks @ataylor32 !

Tip: In your code above, you can use hidden method, to create a hidden field, this way:

{!!Form::hidden('allow_comments', '0')!!}