Spica Posted March 3, 2015 Share Posted March 3, 2015 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 More sharing options...
Jan Romero Posted March 3, 2015 Share Posted March 3, 2015 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 More sharing options...
Spica Posted March 4, 2015 Author Share Posted March 4, 2015 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 More sharing options...
Wanze Posted March 4, 2015 Share Posted March 4, 2015 I would go the javascript route, it's a one-liner in JQuery Link to comment Share on other sites More sharing options...
Spica Posted March 4, 2015 Author Share Posted March 4, 2015 want to change it role based. so its getting complicated with jquery. Link to comment Share on other sites More sharing options...
LostKobrakai Posted March 4, 2015 Share Posted March 4, 2015 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. 1 Link to comment Share on other sites More sharing options...
Spica Posted March 4, 2015 Author Share Posted March 4, 2015 great, this is it function saveButtonText(HookEvent $event) { $form = $event->return; $submitbutton = $form->get('submit_save'); $submitbutton->attr('value', 'myButtonText'); } Link to comment Share on other sites More sharing options...
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