panique / huge

Simple user-authentication solution, embedded into a small framework.
2.14k stars 788 forks source link

Renderfeedbackmessages #847

Closed chan007 closed 7 years ago

chan007 commented 7 years ago

What do I do if I have to render feedback messages at multiple at multiple places in the view? In my case, I have a footer on my web page which has a contact us section. So the notification, of a mail being sent or not, must be displayed there. Also, in the login section, if the user mistypes a password or something, I have to display the error messages on the same page. Any pointers would be appreciated. Thank you.

sr-verde commented 7 years ago

That is easy to implement…

You have to introduce a new feedback-class for each position like that: Session::add('feedback_negative_position', Text::get('FEEDBACK_NOTE_CREATION_FAILED'));

Print out the feedback messages at each position like that:

$feedback_negative = Session::get('feedback_negative_position');

// echo out negative messages
if (isset($feedback_negative)) {
    foreach ($feedback_negative as $feedback) {
        echo '<div class="feedback error">'.$feedback.'</div>';
    }
}
chan007 commented 7 years ago

I figured it out. Thank you.