laravelbook / laravel4-powerpack

Brings back HTML, Form and Str helper classes to Laravel 4!
http://laravelbook.com/
83 stars 14 forks source link

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

Open jackperry opened 11 years ago

jackperry commented 11 years ago

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 commented 11 years ago

Try

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

mikeerickson commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

This code (snippet) works fine here

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

    {{ Form::hidden('id', $contact->id) }}
    {{ Form::hidden('page', Input::get('page')) }}
jackperry commented 11 years ago

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 commented 11 years ago

Any chance you have Meido forms or PowerPacks installed?

jackperry commented 11 years ago

I have powerpack installed yeah.

mikeerickson commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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

jackperry commented 11 years ago

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

mikeerickson commented 11 years ago

So, the function declaration is as follows

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

Not sure where the override is located?

mikeerickson commented 11 years ago

So that tells me the following should work

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

mikeerickson commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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

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

jackperry commented 11 years ago

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 (https://github.com/laravelbook/laravel4-powerpack/issues/9#issuecomment-14692821).

codebyray commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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 commented 10 years ago

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

Ajaykatoch47 commented 10 years ago

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?