Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormBuilder::open() wants an array? #9

Open
jackperry opened this issue Mar 10, 2013 · 26 comments
Open

FormBuilder::open() wants an array? #9

jackperry opened this issue Mar 10, 2013 · 26 comments

Comments

@jackperry
Copy link

My form open line is currently:

{{ Form::open('login', 'POST') }}

But it's returning this error:

ErrorException: Catchable Fatal Error: Argument 1 passed to Illuminate\Html\FormBuilder::open() must be of the type array, string given, called in /Users/jack/Projects/x/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 138 and defined in /Users/jack/Projects/x/vendor/laravel/framework/src/Illuminate/Html/FormBuilder.php line 77

Everything in the docs seems to be pointing to my Form::open line being correct, but I'm getting this. Ideas?

@mikeerickson
Copy link

Try

{{ Form::open('login',array('method' => 'POST')) }}

@mikeerickson
Copy link

In addition, if you have updated to the latest build of Laravel (composer update) the new form class should work with the way you have it (thats how it is working for me). I know a recent update of From class was updated to support the original syntax.

@jackperry
Copy link
Author

I tried that and it didn't work, but I made it empty ({{ Form::open() }}) and it worked. However I'm sure this isn't a smart solution.

I am using the latest build of Laravel.

@mikeerickson
Copy link

The syntax you are using works fine for me. Make sure your composer.json file has (otherwise I have found Form and Str classes are updated correctly)

    "laravel/framework": "4.0.x-dev",

@mikeerickson
Copy link

This code (snippet) works fine here

{{ Form::open('contacts.update','POST') }}

    {{ Form::hidden('id', $contact->id) }}
    {{ Form::hidden('page', Input::get('page')) }}

@jackperry
Copy link
Author

Ah, I was running "4.0.x" and not "4.0.x-dev", but I just changed it and did composer update and {{ Form::open('login','POST') }} still won't work. Same error.

@mikeerickson
Copy link

Any chance you have Meido forms or PowerPacks installed?

@jackperry
Copy link
Author

I have powerpack installed yeah.

@mikeerickson
Copy link

My guess it is conflicting since they both have same class names and method names. What features of PowerPacks do you need (use)? L4 latest pretty much has all that is in PowerPacks.

@jackperry
Copy link
Author

I installed PowerPacks for the HTML and Form classes. You're saying the latest Laravel 4 includes these now? Why was I getting the error before I switched to "4.0.x-dev" then, and I know HTML class wasn't found before I installed PowerPacks. Weird.

@mikeerickson
Copy link

Yes indeed (they will be installed with the -dev build)

Look in the "vendor/laravel/framework/src/illuminate/Html/" directory

You should have both FormBuilder and HtmlBuilder classes (now that you have updated to -dev)

@jackperry
Copy link
Author

Interesting, however even after removing the PowerPack classes, the dev ones are producing the same error (must be of the type array), even though you said it supports the old method. Is my install borked or something? o_O;;

@mikeerickson
Copy link

Did you do a composer update after removing PowerPacks from composer.json? I know it works (using it here no problem).

@jackperry
Copy link
Author

I did, yep. Removed PowerPacks from composer.json, removed the providers and aliases from app.php, and ran composer update.

@mikeerickson
Copy link

So, the function declaration is as follows

public function open(array $options = array())

Not sure where the override is located?

@mikeerickson
Copy link

So that tells me the following should work

{{ Form::open(array('action' => 'login', 'method' = 'POST' )) }}

@mikeerickson
Copy link

Well, look at that! I still have PowerPacks installed so it appears that is what is actually being used as opposed to Laravel internal framework. That would explain why mine is still working.

@mikeerickson
Copy link

Sorry to lead you astray... This whole time I thought I had completely removed PowerPacks but alas I have not (I am still using it for HTML class operations) When I removed PowerPacks myself it broke my app big time and I don't have time to fix all the places at the moment so I have reinstalled.

@mikeerickson
Copy link

So, again this code should make it work for YOU (I will fix my code later)

{{ Form::open(array('action' => 'login', 'method' = 'POST' )) }}

@jackperry
Copy link
Author

Haha, well that explains things! Thanks!

On Sunday, March 10, 2013 at 8:20 PM, Mike Erickson wrote:

So, again this code should make it work for YOU (I will fix my code later)
{{ Form::open(array('action' => 'login', 'method' = 'POST' )) }}


Reply to this email directly or view it on GitHub (#9 (comment)).

@codebyray
Copy link

While I am new here I figured I would post how I got around this issue.

While the below throws and error:
{{ Form::open('user/login', 'POST', array('id' => 'login-validate')) }}

If you just change the order and pou the extra options array first it works as expected.
{{ Form::open(array('id' => 'login-validate'), 'user/login', 'POST') }}

Hope this helps.

@codebyray
Copy link

The conflict is with Illuminate\Html\HtmlServiceProvider as it is trying to reference the Html for Illuminate instead of the HTML package included.

Once I commented out: Illuminate\Html\HtmlServiceProvider in the providers and
'Html' => 'Illuminate\Html\HtmlBuilder', in the aliases it worked as expected.

Hopes this helps with fixing this issue.

Regards,
Ray

@Nicolab
Copy link

Nicolab commented May 13, 2013

Or in the config/app.php, replace :
'Html' => 'Illuminate\Support\Facades\Html',
by
'Html' => 'Illuminate\Support\Facades\HTML',

To avoid this problem, everything should be in camel case (URL => Url, DB => Db, HTML => Html, ...). Brief a single naming convention, not arbitrary as it is.

@ghost
Copy link

ghost commented Jun 29, 2013

Hi, I think we had the same problem. I found out that you should indicate a url variable in an array on the first parameter. Shows like this,

{{ Form::open(array('url' => 'foo/bar')) }}

I hope this would help.

@briiyaann
Copy link

Hi, You can try this syntax,
{{ Form::open(array('action' => 'login', 'method' => 'POST' )) }}

@Ajaykatoch47
Copy link

My form open line is currently:
{{ Form::open(array('action' => 'login', 'method' = 'POST' )) }}

But it's returning this error:

Argument 1 passed to Illuminate\Html\FormBuilder::open() must be of the type array, string given, called in /opt/lampp/htdocs/lara/lp/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 211 and defined (View: /opt/lampp/htdocs/lara/lp/app/views/login.blade.php)
Everything in the docs seems to be pointing to my Form::open line being correct, but I'm getting this. Ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants