StuffedGoat's avatar

[L5] 'files'=>true doesn't work

Hello there,

I'm experiancing issues when using 'files'=>true in one of my view. Let's start with the code of my view:

@if(isset($somethingID))
    {!! Form::open(array('action' => array('Backend\TestController@updateSomething', $somethingID, 'files'=> true))) !!}
@else
    {!! Form::open(array('action' => 'Backend\TestController@storeSomething', 'files'=> true)) !!}
@endif 

The scenario is that I want to edit or upload a picture. The else-block work fine and everything is okay.

But when I want to edit the picture, the first Form::open will be used, it doesn't work. There is no error message or something similar. He just don't uploads the image.

I also tried this but without luck.

{!! Form::open(array('action' => array('Backend\TestController@updateSomething', $somethingID, 'files'=> true, enctype="multipart/form-data"))) !!}

This really bugs me because the only difference is that I need to pass a variable.. nothing more. And on the official docs I don't find a hint. I even don't get why Taylor deletes all the usefull sections in the docs for "Forms" and stuff like that.

I appreciate any help!

0 likes
2 replies
StuffedGoat's avatar
StuffedGoat
OP
Best Answer
Level 2

Found my mistake, hope that will help somebody in the future!

I had to put the 'files' => true outside of the inner array.

From this:

{!! Form::open(array('action' => array('Backend\TestController@updateSomething', $somethingID, 'files'=> true))) !!}

To this:

{!! Form::open(array('action' => array('Backend\TestController@updateSomething', $somethingID), 'files'=> true)) !!}
gpopoteur's avatar

@StuffedGoat yes, as you mentioned, the 'files' => true is an option to the Form::open() method, therefore it should be in the Form::open() options array and not on any other place. Glad you could find the answer :)

1 like

Please or to participate in this conversation.