Copied to clipboard

Flag this post as spam?

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


  • Craig Cronin 304 posts 503 karma points
    Jan 12, 2015 @ 17:32
    Craig Cronin
    0

    Using the Umbraco Dictionary for my MVC model error messages??

    I'm currently building a bilinqual website but have run into a problem with my model error messages.  I need to tap into the Umbraco dictionary items really so that they can be controlled from the admin section and support multiple languages.

    Any help would be appreciated or just point me in the right direction :)

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jan 12, 2015 @ 19:27
    Dennis Aaen
    0

    Hi Craig,

    Perhaps this blogpost from Warren Buckley http://creativewebspecialist.co.uk/2014/04/17/umbraco-mvc-regionalisation-of-error-messages/ can help you in the right direction.

    Hope this helps,

    /Dennis

  • Craig Cronin 304 posts 503 karma points
    Jan 12, 2015 @ 20:37
    Craig Cronin
    0

    Hi Dennis,

    Firstly thanks for the reply.  Yes I came across this solution which is probably the route I will have to go.  Just wanted to check if there was something even easier available though before I implement the custom attribute.

    There are so many new features being added constantly and I've just upgraded the project to 7.2 :)

    Thanks again Dennis.

    Craig

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jan 12, 2015 @ 21:16
    Dennis Aaen
    0

    Hi Craig,

    As you probably already know there are some predefined code snippets for Login, Member profile, and so on there you also have validation messages.

    Here is an example on using dictionary items, in this, perhaps it can help you too.

    http://our.umbraco.org/forum/umbraco-7/using-umbraco-7/57058-Localization-of-member-login-field-labels

    /Dennis

  • Yakov Lebski 591 posts 2346 karma points
    Jan 12, 2015 @ 22:03
  • Craig Cronin 304 posts 503 karma points
    Jan 13, 2015 @ 14:01
    Craig Cronin
    0

    Thanks both for the posts.

    Both really helped and pointed out a really nice simple solution @Html.LabelFor(model => model.Email, Umbraco.DictionaryValue("..."))

    Keeps things very simple :)

  • Yakov Lebski 591 posts 2346 karma points
    Jan 13, 2015 @ 14:07
    Yakov Lebski
    1

    I think you will have issue with validation messages

  • Craig Cronin 304 posts 503 karma points
    Jan 13, 2015 @ 14:10
    Craig Cronin
    0

    Hhhhhmmmm.

    Forgot abou that one.  Does your package deal with validation messages as well?

  • Yakov Lebski 591 posts 2346 karma points
    Jan 13, 2015 @ 14:12
    Yakov Lebski
    0

    Yep, it's automatically build expression for all meta data properties like display name, validation and labels

  • Craig Cronin 304 posts 503 karma points
    Jan 14, 2015 @ 15:12
    Craig Cronin
    0

    Hi Yakov,

    I've been looking at this problem for the past 2 days, I've looked at the solutions from Warren and Ismail but your solution seems to be the only one working in the newer versions Umbraco 7.1.*, 7.2.*.

    Thanks for taking the time, its really been a big help :)

  • Yakov Lebski 591 posts 2346 karma points
    Jan 14, 2015 @ 16:04
    Yakov Lebski
    0

    This works on 6.X too, I not tested current package, but the same code works at 6.X

  • Craig Cronin 304 posts 503 karma points
    Mar 13, 2015 @ 11:44
    Craig Cronin
    0

    Hi Yakov,

    I'm back to this issue again and currently using your package. This seems to work FormContactUsView.Email but if i try and get the required message 

    FormContactUsView.Email.Required

     

    But this doesnt seem to pull the required message through?

     

    public class FormContactUsViewModel
    {
    #region Properties

    [Required]
    public string Name { get; set; }

    [Required]
    public string Email { get; set; }

    [Required]
    public string Message { get; set; }

    #endregion
    }

  • Yakov Lebski 591 posts 2346 karma points
    Mar 13, 2015 @ 13:55
    Yakov Lebski
    1

    Hi, You are right, I have some issue with it.

    My idea was use format for required fields like "The field {0} is required", where {0} is field name.

    For use it you need create additional dictionary RequiredFormat ="The field {0} is required" and it's automatically will work for you.

    I'll fix this issue shortly and I'll put all code in public git for future collaboration.

  • Osman Coskun 170 posts 404 karma points
    Dec 14, 2017 @ 12:24
    Osman Coskun
    0

    Thanks Yakov.

  • Craig Cronin 304 posts 503 karma points
    Mar 13, 2015 @ 13:57
    Craig Cronin
    0

    I've got it working.  What i noticed was if I used Jquery Validation and Jquery Unobtrusive etc all worked fine :)

    Thanks for getting back to me Yakov.

  • Osman Coskun 170 posts 404 karma points
    Dec 19, 2017 @ 11:04
    Osman Coskun
    0

    Hello,

    The package works smooth.

    But i couldn't figure out how to customize default email validation message if the entered email is not valid. The default message is something like :

    The eMail field is not a valid e-mail address.

  • Yakov Lebski 591 posts 2346 karma points
    Dec 19, 2017 @ 11:23
    Yakov Lebski
    0

    You can use in this way

    [ModelName].[PropertyName].[AttributeName]

    for example

    class ->ContactFormModel property Email, email property decorated with [EmailAddress]

    token in the dictionary ContactForm.Email.EmailAddress

    will be shown only for email validation

  • Osman Coskun 170 posts 404 karma points
    Dec 19, 2017 @ 11:39
    Osman Coskun
    0

    That's cool. Thank you.

    In member register model i have password field below. Do you have any idea how to display customized invalid password message.

    [Required]
    [StringLength(30, MinimumLength = 6)]
    public string Password { get; set; }
    
  • Yakov Lebski 591 posts 2346 karma points
    Dec 19, 2017 @ 11:41
    Yakov Lebski
    0

    Hm .... maybe ContactForm.Password.StringLength can work for you ?

  • Osman Coskun 170 posts 404 karma points
    Dec 19, 2017 @ 11:43
    Osman Coskun
    0

    Bingo Yakov :)

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft