Jump to content

Recommended Posts

Posted

Is it is possible to show native ProcessWire notices (errors and messages) in a PW modal (pw-modal) or alternatively on inputs in that modal?

Thanks.

Posted

Not sure I understand what you mean, but the native notices do appear regardless of whether an admin page is viewed in a modal (?modal=1) or not.

Or do you mean you want to prevent the notices from appearing normally and open a modal window that only displays the notices?

Posted

Hmm. They've never showed up for me. What I want is for notices to show up as normal when I save, regardless of whether I am in a modal or a normal window. When I save any page in a modal (e.g. try editing a page in Batcher or a post in Blog) or when I edit and save any custom module page (e.g. some settings page in Media Manager)  in a modal and call $this->message() or $this->error(), they never get shown. 

Posted
4 minutes ago, kongondo said:

When I save any page in a modal (e.g. try editing a page in Batcher or a post in Blog) or when I edit and save any custom module page (e.g. some settings page in Media Manager)  in a modal and call $this->message() or $this->error(), they never get shown.

That's strange. I didn't test with real modals (just appended "modal=1" to the urls) but see the screenshots below of Page Edit and a module config.

2016-12-18_103531.png2016-12-18_103409.png

Maybe something is different when the page is really inside a modal.

Posted

I need to test with the older/original PW notifications then. See below for test with the 'new' System Notifications module: Normal window notices show up OK; modal window ones do not show up at all.

 

normal_window_save_notice.gif

modal_window_save_notice.gif

Posted

Yep...That was it. System Notifications notices don't show up when in a modal. The 'normal/older' notifications show up OK in a modal.

  • Like 1
Posted

Yeah, ta. But that means I can't use System Notifications. It reverts to the old notifications. It also means that I need to tell users of my module to have that setting off (Leave them alone) if they want to see notices in modals. Not great. Anyway, thanks guys. Currently, I am using a custom jQuery solution to show notices in modals....but still curious why System Notifications is turned off in modals

Posted

You could use a hook to override the decision not to show notifications in modals:

$this->addHookAfter('AdminTheme::getExtraMarkup', function($event) {
    if($this->input->get('modal')) {
        $this->modules->get('SystemNotifications')->hookAdminThemeGetExtraMarkup($event);
    }
});

 

Posted

I'd imagine, that's because system notifications would run in the main window as well as in the modal at the same time, because of it's ajax functionality. That's most likely not the result one does hope for.

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...