Uniform Calc Guard Error

Hi,

I am hoping to get some help with the Uniform plugin, and Calc guard. I think Uniform is working as is, but when I add the Calc guard, I get the following error in the Kirby CMS Debugger:

Class 'l' not found

If I reading the debugger correctly, it seems like the error is being hit on line 24 of /Users/chris/Documents/Development/lfa-bh100/vendor/mzur/kirby-uniform/src/helpers.php when it hits:

return str::encode($a.' '.l::get('uniform-calc-plus').' '.$b);

My relevant code in the template is:

<form action="<?php echo $page->url() ?>" method="POST">
   <input name="email" type="email" value="<?php echo $form->old('email'); ?>">
   <textarea name="message"><?php echo $form->old('message'); ?></textarea>
   <label>Please calculate <?php echo uniform_captcha() ?></label>
   <?php echo captcha_field('result', 'my-class'); ?>
   <?php echo csrf_field(); ?>
   <?php echo honeypot_field('url', 'honeypot'); ?>
   <input type="submit" value="Submit">
</form>
<?php if ($form->success()): ?>
   Success!
<?php else: ?>
   <?php snippet('uniform/errors', ['form' => $form]); ?>
<?php endif; ?>   

and in the controller:

<?php

use Uniform\Form;

return function ($kirby)
{
    $form = new Form([
        'email' => [
            'rules' => ['required', 'email'],
            'message' => 'Please enter a valid email address',
        ],
        'message' => [
            'rules' => ['required'],
            'message' => 'Please enter a message',
        ],
        'captcha' => [
            'rules' => ['required', 'num'],
            'message' => 'Please fill in the anti-spam field',
        ],
    ]);

    if (kirby()->request()->is('POST')) {
        $form
            ->honeypotGuard(['field' => 'website'])
            ->calcGuard(['field' => 'captcha'])
            ->logAction([
                'file' => kirby()->roots()->site().'/messages.log'
            ]);
    }    

    return compact('form');
};

I’m also curious if Uniform is the best plugin for my needs. I have a form that I prevent from sending any data, but I grab the values entered to update Firebase via JS. My thought is adding Uniform will create some additional security, but I’m not sure this is the best way to do this…

Any help with both of these questions is much appreciated – thank you!

Looks like you are using an old version of the plugin with Kirby 3?

There is no such line in release 5.0.1

updating to 5.0.1 solved the issue, thank you for pointing that out!

in case anyone else wants to avoid this issue in the future, originally i had downloaded the plugin here:

https://github.com/mzur/kirby-uniform

i’m not sure if i pulled from the v2 branch or not, but i think that had set up the vendor folder incorrectly (i had also tried installing a plugin dependent on uniform via composer that may have created the vendor folder).

i uninstalled those plugins via composer, then downloaded the plugin from kirby’s plugin site:

https://getkirby.com/plugins

and everything is working.

thank you again @texnixe for your help and prompt reply!