thomas Posted May 3, 2017 Posted May 3, 2017 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
Robin S Posted May 4, 2017 Posted May 4, 2017 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. 1
bernhard Posted April 2, 2020 Posted April 2, 2020 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 ? $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) 3
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now