Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Hayden 32 posts 170 karma points
    Jun 13, 2017 @ 23:06
    Hayden
    0

    Issue with form feedback for register / login forms

    Hi All,

    I have installed merchello 2.5 + fasttrack 2.5 & out of the box I'm having issues with data validation on the login / register forms.

    Basically the issue is whenever you submit the login form, it does not provide any form feedback (like username does not exist, password is incorrect). The same goes for register form (no 'this username is already' taken).

    However looking at the source code it looks like this work has been done, but it's just not showing up on the front-end. I've installed merchello + fasttrack out of the box and I'm having the issue still so I'm 99% sure it's not something on my end.

    https://github.com/Merchello/Merchello/blob/merchello-dev/src/Merchello.FastTrack/Controllers/Membership/CustomerMembershipController.cs (Line 96 for login - 142 for register).

    Has anybody found a fix for this, or is there a way to access ViewData["MerchelloViewData"] on my end so I can display the error messages :).

    Cheers, Hayden

  • Puck Holshuijsen 183 posts 726 karma points
    Jun 15, 2017 @ 07:46
    Puck Holshuijsen
    1

    I just found out, that by default Fasttrack does not pick up the messages on the front-end. So you need to add it yourself.

    Here is my ftForgotPassword.cshtml for example:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<FtForgotPassword>
    @{
        Layout = "Master.cshtml";
        dynamic merchelloViewData = ViewData["MerchelloViewData"];
        string message = string.Empty;
        if (merchelloViewData != null)
        {
            foreach (string mes in merchelloViewData.Messages)
            {
                message += mes;
            }
        }
    }
    <div class="container">
        @Html.Partial("_Headline")
        <div class="container">
            <div class="row">
                <div class="col-md-6">
                    @Html.Action("ForgotPasswordForm", "CustomerMembership", new { area = "FastTrack" })
                </div>
            </div>
            @if (merchelloViewData != null && !merchelloViewData.Success)
            {
                <div class="row">
                    <div class="col-xs-12">
                        @message
                    </div>
                </div>
            }
        </div>
    </div>
    

    I am currently working on this page, but i thought it might help you out to get started.

    Puck

  • Hayden 32 posts 170 karma points
    Jun 15, 2017 @ 21:10
    Hayden
    0

    Legend thank you!

    That's perfect, I've updated your code to include the success message as well (and uses default bootstrap alert boxes).

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<FtForgotPassword>
    @{
        Layout = "Master.cshtml";
        dynamic merchelloViewData = ViewData["MerchelloViewData"];
        string message = string.Empty;
        if(merchelloViewData != null)
        {
            foreach (string mes in merchelloViewData.Messages)
            {
                    message += mes;
            }
        }
    }
    <div class="section content page">
        <div class="container backed">
            <div class="row">
    
            @if (merchelloViewData != null && !merchelloViewData.Success)
            {
                   <div class="col-md-6 col-md-offset-3">
                        <div class="alert alert-danger">@message</div>
                   </div>
            }
            else if(merchelloViewData != null && merchelloViewData.Success)
            {
                <div class="col-md-6 col-md-offset-3">
                    <div class="alert alert-success">@message</div>
                </div>
            }
            <div class="col-md-6 col-md-offset-3">
                @Html.Action("ForgotPasswordForm", "CustomerMembership", new { area = "FastTrack" })
            </div>
        </div>
    </div>
    

    For your login page you do exactly the same method -> all credit to @puck above.

  • Puck Holshuijsen 183 posts 726 karma points
    Jun 19, 2017 @ 06:09
    Puck Holshuijsen
    0

    Thanks for the feedback!

    Glad you found my sample code useful! I will use your changes to display the data ;)

    Puck

Please Sign in or register to post replies

Write your reply to:

Draft