Flex's avatar
Level 4

{!! Form::model($image,['method'=>'put','files'=>true]) !!}

what is the meaning of this laravel collective form


 @if(isset($image))
                {!! Form::model($image,['method'=>'put','files'=>true]) !!}
            @else
                {!! Form::open(['files'=>true]) !!}
            @endif

how can I convert it to normal form?

0 likes
2 replies
lostdreamer_nl's avatar

It checks if you have an existing image, if so: make sure that the values are used to prefill the form (Form::model($image)) it makes sure it's got a PUT method (GET / POST / PUT / PATCH / DELETE) and sets the enctype="multipart/form-data" ('files'=>true)

If it does not have an existing image, it simply creates a POST form with enctype="multipart/form-data"

So to put it in normal Blade / HTML:

@if(isset($image))
    <form method="post" enctype="multipart/form-data">
    <input type="hidden" name="_method" value="put">
@else
    <form method="post" enctype="multipart/form-data">
@endif

But now you also need to check for each field, if the field can be prefilled from the $image object.

[beat me by 2 seconds :@]

Please or to participate in this conversation.