Jump to content
thomas

Extending the admin "Save" button

Recommended Posts

I would like to extend the Admin Save button with another SaveAction but can't figure it out:

 

$this->addHookAfter("ProcessPageEdit::buildForm", $this, "editForm");

public function editForm(\Processwire\HookEvent $form) {
	$target = $form->get('submit_save');
	$target->addActionValue('test','Test','');
	$form->return = $form;
}

This gives me another small dropdown button with a single option.

I only managed to add another button to the form (not quite as elegant but would do the job) but my question is if it is possible to use ProcessPageEdits processSave() method and add to it? I need a button that would save the page, add a message and return to a custom URL in the admin.

 

Thanks!

thomas

 

Share this post


Link to post
Share on other sites

It looks like ProcessPageEdit does not use the addActionValue() method but builds the dropdown independently: https://github.com/processwire/processwire/blob/3fc9f69da75e1bc4a3f0842f12a57bd6a1b65099/wire/modules/Process/ProcessPageEdit/ProcessPageEdit.module#L454-L491

Doesn't seems like it would be easy to modify that - probably via JS would be the only way. Maybe you could open a GitHub request asking to make it easier to modify that dropdown menu.

 

  • Like 1

Share this post


Link to post
Share on other sites

Don't know if anything changed since 2017 and just found this post by coincidence but wanted to show how this can be done easily now in 2020 😉 

3CDkwSX.png

$wire->addHookAfter('ProcessPageEdit::getSubmitActions', function(HookEvent $event) {
  $actions = $event->return;
  $actions[] = [
    'value' => 'foo',
    'icon' => 'check',
    'label' => 'foo',
  ];
  $event->return = $actions;
});

The value of the clicked submit action is stored in $input->post->_after_submit_action (you can hook Pages::saved or ProcessPageEdit::processInput)

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...