Uniform - Trouble adding custom action

Hi,

I’m having trouble adding a custom action to the Uniform plugin. I think I’m missing something basic here:

  1. I created the file uniform-actions.php in site/plugins

  2. The content of the file:

     <?php
       namespace Uniform\Actions;
    
       class BlaBlaBla extends Action
           {
               public function perform()
               {
                   try {
                       var_dump($this->form->data());
                   } catch (\Exception $e) {
                       $this->fail($e->getMessage());
                   }
               }
           }
    
  3. Then I call the new action with
    if (r::is(‘POST’)) {
    $form->blaBlaBla();

However nothing happens and the new action is not found. If I use the standard DumpAction instead everything works fine. What am I missing here?

It is also not working if I place the plugin file in a /uniform-actions subdirectory.

I installed Uniform as a git submodule.

Thank you!
Georg

If you want to be able to call the action via a magic method it must have the Action suffix in its name. This information was missing from the docs, I’ve fixed that.

So call your class BlaBlaBlaAction and it should work with $form->blaBlaBlaAction(). The other methods to execute an action will always work, no matter what your custom action is called.

1 Like

Thank you – that did the trick!