dotnetic Posted March 21, 2017 Share Posted March 21, 2017 I want to load a module or page in the ProcessWire Admin in a modal. Right now, I added a button on the Edit page and gave that button a class of "pw-modal". When I click this button, the modal opens with the provided URL, but then suddenly the browser redirects me to this URL. This is not how it should work. In the screencast you can see what´s happening. Here is the code that I use to add the button to the form: public function ready() { $this->addHookAfter('ProcessPageEdit::buildForm', $this, 'addButtons'); } /** * Add a button besides "Save", which lets the user accept the application * */ public function addButtons($event) { $page = $event->object->getPage(); if ($page->template == "bewerbung") { $form = $event->return; $accept = $this->modules->get('InputfieldButton'); $accept->attr('id+name', 'hook_accept_application'); $accept->attr('href', 'http://localhost/winkelmann/www/bewerbertool-talents/admin/page/edit/?id=1479'); $accept->class .= ' ui-priority-secondary head_button_clone pw-modal'; $accept->attr('value', $this->_('Bewerbungsunterlagen anfordern')); $form->append($accept, $form->get("id")); } } 2017-03-21_10-20-51.mp4 Link to comment Share on other sites More sharing options...
dotnetic Posted March 21, 2017 Author Share Posted March 21, 2017 The problem seems to be that the button submits the form. If I transform it into a link, the modal works fine, but the links does not look like a button. Link to comment Share on other sites More sharing options...
gmclelland Posted January 12, 2018 Share Posted January 12, 2018 I know this old, but the answer to this question is to add: $accept->attr('data-href', wire('config')->urls->admin . 'page/edit/?id=1479'); Remove this line: $accept->attr('href', 'http://localhost/winkelmann/www/bewerbertool-talents/admin/page/edit/?id=1479'); Hope that helps the next person. 3 1 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