formers / former

A powerful form builder, for Laravel and other frameworks (stand-alone too)
https://formers.github.io/former/
1.34k stars 204 forks source link

Bootstrap 4 throws error without open and close tag #588

Closed CedNet closed 5 years ago

CedNet commented 5 years ago

Wanted to switch over to Bootstrap 4 and when I do that any page that has a use of {!! Former::x() !!} (without an open and close tag) throws an error "Class former.form does not exist" in the file at line 254:

public function getGroupClasses() { if ($this->app['former.form']->isOfType('horizontal')) { return 'form-group row'; } else { return 'form-group'; } }

I use the Former to generate some random inputs on screen without the need of an actual full form. Can I somehow get around this?

It worked fine in Bootstrap 3.

I can't myself figure it out or I'd have send a PR.

I'm using the default former.php config file.

CedNet commented 5 years ago

I found the issue and sent in a PR for a fix. Tests have passed and the fix is simple enough to just check whether former.form exists before checking type. Hence making it optional to define an opening tag (how it works with Boostrap3)

claar commented 5 years ago

Hi @CedNet,

Thanks so much for the issue report and PR. The Former::open() call isn't currently optional. There are multiple places in the codebase that depend on open() having been called before using other classes such as Former::checkbox('foo').

Changing this assumption would be a welcome PR, but I imagine it would be a large effort. This package is currently only offering maintenance support at the moment, not new development, so such a change would have to come from others.

Thank you!