Torsten Baldes Posted October 23, 2014 Posted October 23, 2014 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!
Macrura Posted October 24, 2014 Posted October 24, 2014 yeah, i actually asked about this over on the pagetable documentation thread https://processwire.com/talk/topic/6546-pagetable-documentation/?p=76627
sforsman Posted October 24, 2014 Posted October 24, 2014 (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 October 24, 2014 by sforsman 4
Torsten Baldes Posted October 24, 2014 Author Posted October 24, 2014 @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?
sforsman Posted October 24, 2014 Posted October 24, 2014 @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. 1
apeisa Posted November 5, 2014 Posted November 5, 2014 There is now setting for this in latest dev. 1
thetuningspoon Posted August 4, 2015 Posted August 4, 2015 I've discovered the "ProcessPageAdd" hack as well
mr-fan Posted August 4, 2015 Posted August 4, 2015 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
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