Closed garygreen closed 9 years ago
Any news on this? @msurguy :-)
@garygreen Merged :)
Thanks!
@garygreen have been getting reports that honeypot update 0.3.0 is displaying this error: "Non-static method Illuminate\Html\FormBuilder::macro() should not be called statically". The error appears when Laravel 4.1 is used. Could you help me debug this?
@msurguy Well I guess I just learned something in PHP today, that you can call static methods non-statically if the class is instantiated. In Laravel 4.2 and above it switched to using the MacroableTrait which meant you can add macros without instantiating the form builder. In 4.1 and below you had to actually instantiate to register the macros. Bit of an oversight on my part.
The main reason why I did this commit was because of reports of not being able to access the honeypot
macro in instances where you used a package that extended Laravel's FormBuilder. It seemed logical to just add the macro by a static call without instantiating, so it would always 'just work' for 4.2 and above in pretty much any situation.
I've done a PR #29 which will fix 4.0 and 4.1, will still attempt to use the MacroableTrait if it's >= 4.2 but fallback the old way for <= 4.1. Sorry about that ! :smile_cat:
@garygreen done and released as 0.3.1!
This fixes cases where the honeypot marco is not added where the form builder hasn't been resolved through the IoC, i.e. if your extending Laravel's form builder