silverstripe-cms icon indicating copy to clipboard operation
silverstripe-cms copied to clipboard

FormAction handler not triggering in a SiteConfig tab

Open digitall-it opened this issue 6 years ago • 1 comments

On SS3.6.5 if you add a FormAction to a tab, it displays fine but it's action is not executed. Tried adding the action handler function and the respective allow_actions array voice in a SiteConfig extension and/or a LeftAndMain extension, but there is no visible effect. In the function I tried to die('test') or to return 'test' or to add a CMS notice banner 'test' in the upper right corner.

One supposition is that the button initiates an XHR request (that I've been unable to catch yet) and so it is expected for the action to return something specific. Another supposition is that the button is simply doing nothing.

The button would start an oAuth sequence. I tried browsing other modules to see what other users have done, and it seems like a common problem, because everyone else has extended a LiteralField to mimic a button (that indeed is a link). I followed the exact same path, but I wonder if there's a bug in the CMS. Just to restate, the button is in the tab and not near the Save button, because that's not a main siteconfig action, it is referred only to that tab.

Steps to replicate the problem:

  1. install SilverStripe v3.6.5
  2. Create a SiteConfig extension
  3. Add a tab in the SiteConfig extension
  4. Add a FormAction to such a tab
  5. Create a LeftAndMain extension
  6. Create the action handler in LeftAndMain and/or in SiteConfig
  7. Click the button, check that the action handler is not triggered

Expected result: By clicking the FormAction button, the action handler is triggered

digitall-it avatar Jul 28 '18 15:07 digitall-it

I had a look at replicating this in SS4.

I added an extra action to the to the site config via getCMSActions. That worked fine. I tried adding an action in getCMSFields ... that didn't work. So we're seeign the same behaviour in SS4.

I'm not convince we should support adding FormActions in getCMSFields however.

maxime-rainville avatar Aug 07 '20 05:08 maxime-rainville