Honeypot
Honeypot copied to clipboard
Does not recognize honeypot method
Might just be me but I'm getting: An exception has been thrown during the rendering of a template ("Method honeypot does not exist.")
in my view. I'm using Twig and access your method as such, form_honeypot('hname', 'htime')
.
I also have my own custom macros which I'm able to access as form_mymacroname('xxx')
so I don't think it's the macro but I might be wrong on this.
Hi,
Does Laravel find the service provider as expected ? Can you call its methods ?
It's really not working. I tried using <?php echo Form::honeypot('h', 't'); ?>
on a non-twig view and I still got Method honeypot does not exist.
. Everything is installed exactly as instructed.
Are you sure you have the service provider added in the app.php? 'Msurguy\Honeypot\HoneypotServiceProvider',
Yes. Btw, I'm using L4.1. Perhaps this version is affecting your package?
I'm using L4.1 and it's ok.
I believe you must add the service provider at the end of the providers array, not at the top. It that all right ?
No, it didn't. Let me check this might be an isolated incident having to do with some of the core classes I've extended.
Does my recent changes to the service provider fix this issue?
I have the exact same problem. I'm using Laravel 4.2 and I've added 'Msurguy\Honeypot\HoneypotServiceProvider' to app.php
@rombat are you using twig too? Do you use twigbridge or anything like that?
Nope I'm using Blade. I've just added {{ Form::honeypot('my_name', 'my_time') }} in a form to test Honeypot.
Here's the Exception:
Open: /home/vagrant/Code/laravel/vendor/laravel/framework/src/Illuminate/Support/Traits/MacroableTrait.php
public static function __callStatic($method, $parameters)
{
if (static::hasMacro($method))
{
return call_user_func_array(static::$macros[$method], $parameters);
}
throw new \BadMethodCallException("Method {$method} does not exist.");
}
Exception message: Method honeypot does not exist.
Can you paste your app.php providers array too please.
'providers' => array(
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
'Illuminate\Cache\CacheServiceProvider',
'Illuminate\Session\CommandsServiceProvider',
'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider',
'Illuminate\Routing\ControllerServiceProvider',
'Illuminate\Cookie\CookieServiceProvider',
'Illuminate\Database\DatabaseServiceProvider',
'Illuminate\Encryption\EncryptionServiceProvider',
'Illuminate\Filesystem\FilesystemServiceProvider',
'Illuminate\Hashing\HashServiceProvider',
'Illuminate\Html\HtmlServiceProvider',
'Illuminate\Log\LogServiceProvider',
'Illuminate\Mail\MailServiceProvider',
'Illuminate\Database\MigrationServiceProvider',
'Illuminate\Pagination\PaginationServiceProvider',
'Illuminate\Queue\QueueServiceProvider',
'Illuminate\Redis\RedisServiceProvider',
'Illuminate\Remote\RemoteServiceProvider',
'Illuminate\Auth\Reminders\ReminderServiceProvider',
'Illuminate\Database\SeedServiceProvider',
'Illuminate\Session\SessionServiceProvider',
'Illuminate\Translation\TranslationServiceProvider',
'Illuminate\Validation\ValidationServiceProvider',
'Illuminate\View\ViewServiceProvider',
'Illuminate\Workbench\WorkbenchServiceProvider',
'Barryvdh\Debugbar\ServiceProvider',
'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider',
'Roumen\Asset\AssetServiceProvider',
'Way\Generators\GeneratorsServiceProvider',
'DaveJamesMiller\Breadcrumbs\ServiceProvider',
'Jenssegers\Agent\AgentServiceProvider',
'Arg\Tagcloud\TagcloudServiceProvider',
'Former\FormerServiceProvider',
'Bootstrapper\BootstrapperServiceProvider',
'Lib\Search\SearchServiceProvider',
'Lib\Validation\ValidationExtensionServiceProvider',
'Kmd\Logviewer\LogviewerServiceProvider',
'Indatus\Dispatcher\ServiceProvider',
'BigName\BackupManager\Integrations\Laravel\BackupManagerServiceProvider',
'Spatie\Glide\GlideServiceProvider',
'Msurguy\Honeypot\HoneypotServiceProvider',
),
if possible, can you comment out/remove these providers and see if it honeypot works?
'Former\FormerServiceProvider',
'Bootstrapper\BootstrapperServiceProvider',
Also are you using the latest dev-master of honeypot? Latest tagged version of honeypot is quite old
Yep, I have "vinicius73/seotools": "dev-master".
It was due to Former actually. My form was opened/closed with Former.
I tried {{ Former::honeypot('my_name', 'my_time') }}
and it works. Well, actually, sort of: only the 'my name' field is added, 'my time' is not.
Is there a way to make it work? I'm using Former and Bootstrapper\Form in almost all my forms.
Weird how the my time field is not added, what's the actual raw HTML output for the honeypot section? You got quite a lot of dependencies to be honest, could be anything.
I did take a look at former and bootstrapper service provider on github as I originally suspected it was replacing Laravel's built in form and therefore overriding the macros, but that doesn't seem like the case. Can you setup a real bare repository on github that replicates the issue in the min number of steps I can take a look.
Ever since this commit: f18c81f814ca7a4f0d82dc76b78d2790b277c0f5
My regular 4.2 application fails with honeypot method does not exist
. I reverted back to the commit prior to that one and everything worked.
@iBotPeaches what's in your app.providers
array?
'providers' => array(
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
'Illuminate\Cache\CacheServiceProvider',
'Illuminate\Session\CommandsServiceProvider',
'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider',
'Illuminate\Routing\ControllerServiceProvider',
'Illuminate\Cookie\CookieServiceProvider',
'Illuminate\Database\DatabaseServiceProvider',
'Illuminate\Encryption\EncryptionServiceProvider',
'Illuminate\Filesystem\FilesystemServiceProvider',
'Illuminate\Hashing\HashServiceProvider',
'Illuminate\Html\HtmlServiceProvider',
'Illuminate\Log\LogServiceProvider',
'Illuminate\Database\MigrationServiceProvider',
'Illuminate\Pagination\PaginationServiceProvider',
'Illuminate\Queue\QueueServiceProvider',
'Illuminate\Redis\RedisServiceProvider',
'Illuminate\Remote\RemoteServiceProvider',
'Illuminate\Database\SeedServiceProvider',
'Illuminate\Session\SessionServiceProvider',
'Illuminate\Translation\TranslationServiceProvider',
'Illuminate\Validation\ValidationServiceProvider',
'Illuminate\View\ViewServiceProvider',
'Illuminate\Workbench\WorkbenchServiceProvider',
'GrahamCampbell\Markdown\MarkdownServiceProvider',
'App\Form\Providers\FormBuilderServiceProvider',
'App\Auth\Providers\PasswordBrokerServiceProvider',
'Intervention\Image\ImageServiceProvider',
'Zizaco\Entrust\EntrustServiceProvider',
'Msurguy\Honeypot\HoneypotServiceProvider',
'Laravel\Cashier\CashierServiceProvider',
'Appitventures\Phpgmaps\PhpgmapsServiceProvider',
'Snowfire\Mail\MailServiceProvider',
'Bugsnag\BugsnagLaravel\BugsnagLaravelServiceProvider',
Can you comment out App\Form\Providers\FormBuilderServiceProvider
and try if honeypot works?
Yes that fixed it, but then removed all my custom Form
functions that I had created, so can't really use that fix.
Of course not, just trying to find the cause. Can you post your FormBuilderServiceProvider?
FormBuilderServiceProvider.php
<?php namespace App\Form\Providers;
use Illuminate\Support\ServiceProvider as IlluminateServiceProvider;
use App\Form\FormBuilder as FormBuilder;
class FormBuilderServiceProvider extends IlluminateServiceProvider {
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = true;
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->bindShared('formbuilder', function($app)
{
$form = new FormBuilder($app['html'], $app['url'], $app['session.store']->getToken());
return $form->setSessionStore($app['session.store']);
});
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return array('formbuilder');
}
}
Does your FormBuilder extends Laravels one? How are you using your custom form builder, do you have a facade?
Yep my custom FormBuilder
extends laravel.
use \Illuminate\Html\FormBuilder as IlluminateFormBuilder;
class FormBuilder extends IlluminateFormBuilder {
Which then changes the Facade in app/config
to point to my custom one, allowing me to use my custom functions in addition to the laravel ones.
'Form' => 'App\Form\FormBuilderFacade',
The new service provider in honeypot will listen for when the form
alias get's resolved from the container, then register all the macros. The default alias in Laravel is form
but I notice you've changed it to formbuilder
in your provider. Can you try changing it to just form
which will override Laravel's built in one.
That worked. Thank you!
No idea why I used formbuilder
vs form
.
@garygreen : here's a test repository with the error: https://github.com/rombat/test-laravel-honeypot It's just a fresh install of Laravel 4.2 with the packages I use on my project, and the default "hello" view edited with honeypot method.
I've created a PR which will help resolve #25