Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

Advanced module - how to add custom 'Data has been saved' notification?

edited February 2012 in Feature Requests
Hey there!

I'm wondering if it'd be possible to send a conditional notification on an advanced module model after an entry has been saved. What I'm trying to do is doing some checks inside the on_after_save hook and if the criteria was matched send a different notification message to the user.
So instead of the green "Data has been saved" i'd love to have something like 'Please don't forget to ...'
Even better, I'd love to be able to "append" so to say an html block in the edit form body once the saving has been done. Just a simple link to another backend section basically.

Any idea on how to achieve this?
I presume i might set some session variable and hack some lines in the module.php controller to take care of them, but I'm hoping there's a cleaner way...


  • edited 12:54AM
    I don't think there is currently a way to do that without changing the source because the setting of that flashdata is the last thing done before redirecting and a model hook wouldn't work there. It may not be a bad idea for the module.php file to have something like the following to detect if the success message has already been set. Or, as an alternative, the fuel/modules/fuel/views/_blocks/notifications.php file could have an additional flashdata value that is displayed before the success message.
    if (!$this->session->flashdata('success')) { $this->session->set_flashdata('success', lang('data_saved')); }
  • edited 12:54AM
    Ok cool, thanks for the input. In general, wouldn't it make sense to have a method that a model could call in one of the various hooks to provide feedback to the user which is not necessarily validation-specific? Just to be verbose :) Something like this (pseudocode)

    on_after_save($values) {
    $this->show_notification('warning', 'Please make sure you also send an email to the customer');
    and what happens is that a flash message is displayed in the notification bar, possibly alongside the 'data has been saved' standard message. Makes any sense?
  • edited 12:54AM
    Yep it does... The next release will have just that but on a Fuel_admin object (e.g. $this->fuel->admin->set_notification('success', 'My Message');.
  • edited 12:54AM
    Thanks admin, it works now :).
    Doc is here -
    And message should look like - $this->fuel->admin->set_notification('Custom message ...', 'success');
Sign In or Register to comment.