Notification Messages

edited January 2011 in Modules
What is the best way to handle the placement and display of notification errors/messages for the demo site? It looks like the cms backend is placing them at the top of the demo site and i would like to place them within the the demo sites main div.

Comments

  • edited 7:04AM
    You will see those error messages at the very top of the page only if you are logged into FUEL because it has an area where it captures all error messages. The error messages should also be replicated in the main view of the page just above the form and should highlight the fields in red that have errors which is what a normal person not logged in will see. Try logging out of FUEL and testing the form and see if that was the issue.
  • edited 7:04AM
    Thanks, that did it and for all the hard work you put into fuel. If I want to replicate the notifications function in the demo, I would like to have a consistent messaging layout across site (forms, etc) what is the best way to implement that? I have copied the notifications block to the the demo block area, added the div to demo header and it looks like $vars[notifications] and $vars[errors] are being generated, but errorring out in the view, by the $notifications echo. Is this the best approach? Please advise.
  • edited 7:04AM
    What's the error you are seeing (when you say errorring out)?

    Also, if you are using the Form_builder class, there is a display_errors property you can set to TRUE, which will display any validation errors generated by the Form_builders Validation object using the validate_helpers.php function display_errors() function.
  • edited 7:04AM
    I was able to get it going both ways, I just added logic similar to yours from the login module:

    $notifications = $this->load->view('_blocks/notifications', $vars, TRUE);
    $vars['notifications'] = $notifications;

    I do not like the idea of having to force the flash data, $this->session->set_flashdata('success', 'message for view')),
    by using the a redirect(fuel_uri()), just to get the messages to populate the view. Is that standard practice for using flashdata in conjunction with messaging or am I missing something? Thanks
  • edited 7:04AM
    The reason there is a redirect and a flash data is so that you can't hit the refresh button and resubmit the page after success. Does that make sense?
  • edited 7:04AM
    Thanks, got it.
  • edited 7:04AM
    HI, I am also getting duplicate errors at the top and above the form. The user in this case will always be logged in, so I need the top screen errors to not show but i still need the errors above the form to show up. I am wondering what can be done? I am using similar code to the contact form and it is working bit I don't like the duplicate errors at the top like the other guy mentioned. Thanks. I decided not to start a new thread yet.
  • edited July 2012
    The errors shows at the very top of the page because a user is logged in and the validator object that the form_builder is using to validate has "register_to_global_errors" turned on. So try turning it off on the validator object that the form_builder object is using like so:
    $validator->register_to_global_errors = FALSE;
  • edited 7:04AM
    I am having the same problem, but your solution does not work.

    First you wrote the same code for both:
    "If you are using just a straight up validator object you can do the following:
    $validator = register_to_global_errors = FALSE;
    If you are using a model's
    $validator = register_to_global_errors = FALSE;"

    In my contact controller if I tried:
    $this->validator = register_to_global_errors = FALSE; $this->form_builder->set_validator($this->validator);
    I get this error: Parse error: syntax error, unexpected '=' in C:\wamp\www\clarenssa\fuel\application\controllers\contact.php on line 34

    If I changed it to:
    $this->validator->register_to_global_errors = FALSE; $this->form_builder->set_validator($this->validator);
    I still see the error at the top.

    So how do I solve this problem please?
  • edited 7:04AM
    I've corrected the typo above. With regards to your issue, is the validator object you are setting register_to_global_errors on the same one you are setting the rules up on and capturing the errors?
  • edited 7:04AM
    I tried with:
    $this->validator->register_to_global_errors = FALSE;
    But error doesn't appear
  • edited 7:04AM
    In my advanced module I used a couple of lines and works fine:

    $this->form_builder->display_errors = FALSE;
    $this->validator->register_to_global_errors = TRUE;
Sign In or Register to comment.