Jump to content

Recommended Posts

Posted

Is it possible to keep the modal open after saving? I regularly edit/test/change some content and it is kind of annoying to reopen the modal when i'm right into editing and just want to see, how it looks in the frontend.

thanks!

Posted (edited)

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
Posted

@sforsman

Thanks for the code snippet! Where do i place this? In a new module or in my _init.php? And if I put it in my _init.php, will it affect (performance, timing etc.) my frontend output? 

Posted

@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
  • 2 weeks later...
  • 8 months later...
Posted

With the PageTableExtended field you chould choose if modal should close or not on save....just to mention this here right now....

regards mr-fan

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
×
×
  • Create New...