Jump to content

Change page edit buttons value


Spica
 Share

Recommended Posts

How to change the buttons value. Have the hook,

$this->addHookBefore('ProcessPageEdit::buildForm', $this, 'pButton');

but dont find any hint how to adress the value of the button which is defined in line 387 in processPageEdit

$submit2->attr('value', $this->_('Save + Keep Unpublished')); // Button: save unpublished
Link to comment
Share on other sites

ProcessPageEdit::buildForm returns an InputfieldForm element. So you want to hook after it’s done creating the form using addHookAfter.

Then you can get the form element like so: $form = $event->return;

Now all you can modify it to your heart’s content. To get the submit button, I think you can simply do $submitbutton = $form->get('submit_save');

Sorry, no copypastable code. I’m on mobile.

Link to comment
Share on other sites

Sorry, but dont get it to work. Tried this.

	function saveButtonText(HookEvent $event) {
			$form = $event->return;
			$submitbutton = $form->get('submit_save_unpublished');
			$submitbutton->attr('value', 'myButtonText');
	}

And actually I want to change only the text of the button. Realized that I am adressing the value, which should stay for the propper functionality of the form.

Link to comment
Share on other sites

Firstly $form->get() does only search by field name, while you supplied the id of the button. Also this id will be used for the "save" and "publish" button, so to differentiate use this names: "submit_save" "submit_publish". Secondly the value of the submit field is not necessary for the form submition, otherwise it would not be translateable. Only the name attr has to stay the same.

  • 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...