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 :)
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 :)
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 :)
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 :)
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
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
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
You can use also named base solution http://our.umbraco.org/projects/developer-tools/umbraco-dictionary-metadataprovider
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 :)
I think you will have issue with validation messages
Hhhhhmmmm.
Forgot abou that one. Does your package deal with validation messages as well?
Yep, it's automatically build expression for all meta data properties like display name, validation and labels
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 :)
This works on 6.X too, I not tested current package, but the same code works at 6.X
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
}
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.
Thanks Yakov.
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.
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.
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
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.
Hm .... maybe ContactForm.Password.StringLength can work for you ?
Bingo Yakov :)
Thanks
is working on a reply...