adamwathan / bootforms

Rapid form generation with Bootstrap 3 and Laravel.
MIT License
417 stars 103 forks source link

Invalid argument supplied for foreach() #63

Closed simplenotezy closed 9 years ago

simplenotezy commented 9 years ago

I am getting this error: Invalid argument supplied for foreach()

In file: /home/forge/staging.domain.com/vendor/adamwathan/bootforms/src/AdamWathan/BootForms/HorizontalFormBuilder.php

protected function getLabelClass()
{
    $class = '';
    foreach ($this->columnSizes as $breakpoint => $sizes) { // this line
        $class .= sprintf('col-%s-%s ', $breakpoint, $sizes[0]);
    }

Triggered when I do:

{!! BootForm::text('Your name', 'name'); !!}

Inside my form I opened like this:

{!! BootForm::openHorizontal(3, 9)->post()->action('/auth/register') !!}

I think it happend after updating my composer file.

My composer:

"require": {
    "laravel/framework": "~5.0",
    "adamwathan/bootforms": "0.6.3",
},

I have also tried going back to version 0.5.0 - but same issue occurs.

simplenotezy commented 9 years ago

I have found this commit from an elder composer.lock file: f4967ba9099f8e6f289ab6d280fcd00dc96fe907, requiring this:

"adamwathan/bootforms": "dev-master#f4967ba9099f8e6f289ab6d280fcd00dc96fe907",

Solves the issue.

adamwathan commented 9 years ago

Hey! The issue is because the API has changed between versions.

This call:

{!! BootForm::openHorizontal(3, 9)->post()->action('/auth/register') !!}

...is no longer correct. You need to specify what breakpoints you want for the columns now:

{!! BootForm::openHorizontal(['lg' => [3, 9]])->post()->action('/auth/register') !!}

More info in the docs: https://github.com/adamwathan/bootforms#horizontal-forms