Jump to content

[solved] How to remove dropdown items from submit button?


bernhard
 Share

Recommended Posts

Found the solution ? 

/**
 * Modify submit button on doc-import pages
 */
$wire->addHookAfter('ProcessPageEdit::getSubmitActions', function(HookEvent $event) {
  $page = $this->pages->get($this->input->get('id'));
  if(!$page->id OR !$page->template == 'docimport') return;
  $event->return = [];
});
$wire->addHookAfter("ProcessPageEdit::buildForm", function(HookEvent $event) {
  $form = $event->arguments(0);
  $page = $this->pages->get($this->input->get('id'));
  if(!$page->id OR !$page->template == 'docimport') return;
  $s = $form->getChildByName('submit_save');
  $s->value = 'Import starten';
  $s->icon = 'download';
});

rjH8kod.png

? 

Does anybody know how I can remove the dropdown items from the page edit submit_save button? As I didn't find a solution quickly I wanted to replace the button entirely, but this results in the following markup:

$wire->addHookAfter('ProcessPageEdit::buildForm', function(HookEvent $event) {
  $form = $event->arguments(0); /** @var InputfieldForm $form */
  $s = $form->getChildByName('submit_save'); /** @var InputfieldSubmit $s */
  $form->remove($s);
});

This hook results in this output:

5ARFpxm.png

I could hide this markup via CSS but I'd prefer a clean solution ? 

Thx!

  • Like 5
Link to comment
Share on other sites

  • 2 years later...

Thanks Bernhard - I had to remove the Save button when adding a new page with a particular template today for a specific reason, so here was my solution which I arrived at thanks to your code above:

$this->addHookAfter("ProcessPageEdit::buildForm", function($event) {
	$page_id = (int)$this->input->get->id;
	$page = $this->pages->get($page_id);
	if ($page->template->name == 'my_template_which_only_needs_publish_but_not_save') {
		$form = $event->arguments(0);

		// We want to check the publish button is actually visible first - usually there is "isNew=1" at the end of the URL but that can be removed 
		// manually so best to use a more thorough check
		$publish_button = $form->getChildByName('submit_publish');
            if ($publish_button) {
                $save_button = $form->getChildByName('submit_save');
                $form->remove($save_button);
            }
		}
	}
});

This will of course revert to just showing the Save button once the page has been saved.

Hope that helps someone in future (probably me in about 6 months time when I forget all about it - that's usually the case ? ).

  • Like 2
Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

My post above actually does what @Pete described but not what the title of this topic says.

Needed to remove a submit action today so the latest dev version of RockMigrations now has this if the page is a magicpage:

public function editForm($form) {
  $rm = $this->rockmigrations();
  $rm->removeSubmitActions(['next', 'exit']);
}

?

  • Like 1
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...