Jump to content

[PageTable] Don't close the modal on saving the PageTable entry


Torsten Baldes
 Share

Recommended Posts

Yes this is possible. However since preventing it is not "natively" supported by ProcessWire, you need to trick it a little bit. This can be done in many ways, but here's one

wire()->addHookAfter("ProcessPageEdit::buildForm", function($e) {
  if(!$this->input->get->modal) return;
  $form = $e->arguments(0);
  $field = $this->modules->get('InputfieldHidden');
  $field->attr('id+name', 'ProcessPageAdd');
  $form->append($field);  
});

Providing a native way would be very simple since the closing of the dialog is controlled by a single variable called closeOnSave in InputfieldPageTable.js.

You could also modify the buttons and whatnot. Also submitting the form in a regular way (e.g. by hitting enter) also prevents the modal from closing. The example I provided tricks the InputfieldPageTable.js to set closeOnSave to false by just adding a hidden field to the form with the ID "ProcessPageAdd" (https://github.com/ryancramerdesign/ProcessWire/blob/576a5d30153f045daa94a136a6ba981650632b26/wire/modules/Inputfield/InputfieldPageTable/InputfieldPageTable.js#L52).

Edit: Added a litte more information

Edited by sforsman
  • Like 4
Link to comment
Share on other sites

@tobaco:

No problem! You can add it into /site/templates/admin.php. This will not affect your frontend output at all, because the admin.php is included only when you are on the admin-site. However it won't really affect your admin-site performance either - it's a very lightweight hook and it's attached only to Page-editing events.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
  • 8 months later...

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

×
×
  • Create New...