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
    Apr 22, 2015 @ 11:10
    Craig Cronin
    0

    Umbraco Validation Attributes

    I've upgraded to Umbraco 7.2 for the new corporate website build which needs to be in both Welsh and English.  I really need my model attributes to be bilinqual and even though in early versions of Umbraco 7 there are various solutions that work, this is no longer the case.

    Getting a little desperate on this now.  Really liked Warren Buckleys solution which previously worked but doesn't in the latest versions?

    Really appreciate any help on this one before my computer goes through the window

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 22, 2015 @ 11:32
    Jan Skovgaard
    0

    Hi Craig

    Not quite sure I get the context - Can you provide a link to the way Warren does it?

    /Jan

  • Craig Cronin 304 posts 503 karma points
    Apr 22, 2015 @ 12:24
  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 22, 2015 @ 22:16
    Jan Skovgaard
    0

    Hi Craig

    Hmm, have you tried pinging either Lee or Warren on Twitter to hear if they have any clue about what could be the issue and how it can be worked around maybe?

    /Jan

  • Craig Cronin 304 posts 503 karma points
    Apr 22, 2015 @ 22:18
    Craig Cronin
    1

    I know Warren was going to look at the issue but he's been so busy.  I forked is code today and 80% through putting a fix in and will be making a pull request on monday with the updates :)

    Thanks Jan

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 22, 2015 @ 22:55
    Jan Skovgaard
    0

    Hi Craig

    Ah, awesome! That's the spirit :)

    So now I'm curious... what's the issue? What changed after 7.1.8 release?

    /Jan

  • Craig Cronin 304 posts 503 karma points
    Apr 23, 2015 @ 09:17
    Craig Cronin
    1

    Hi Jan,

    I'm not sure what changed in the core but when I was stepping through the source code, the attribute contstructor was only running once on application start.  This meant if I refreshed the app pool and navigated to the english site all worked.  If I then clicked to view the welsh site it still showed the english attribute values.

    Again, if i refreshed the app pool and viewed the welsh content all worked fine until i switched languages and tried to view the english content. Personally i feel with the big push on razor and mvc this is something that should really be in the core.

    Through investigation I noticed there were other solutions but Warren's custom attribute project was the most elegant really and gave more control, so it will be good to get this up and running again.

  • Jason Espin 368 posts 1335 karma points
    Jun 22, 2015 @ 11:53
    Jason Espin
    0

    So just so I am aware, is this working again now or is your pull request still waiting to be merged into the overall project?

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jun 22, 2015 @ 11:56
    Ismail Mayat
    0

    Bit late to party I did one a while ago https://github.com/ismailmayat/MvcUmbracoDataAnnotations its v7 but you could update the umbraco stuff to v7 using nuget ??

    Regards

    Ismail

  • Craig Cronin 304 posts 503 karma points
    Jun 22, 2015 @ 11:58
    Craig Cronin
    0

    Hi Jason,

    Yes all should be working again now. I made a pull request a couple of weeks ago and as far as I know its been merged :)

    I have it running locally on 7.2.* and all working fine.

  • Craig Cronin 304 posts 503 karma points
    Jun 22, 2015 @ 12:02
    Craig Cronin
    0

    Hi Ismail, I did come across your solution and even though part of it worked on the new versions of 7 it run into the same problems that Warren's solution did.

    I can't quite remember how far I got with your solution but it worked in the earlier versions of 7 just like Warren's but something changed in the newer versions of 7.

    Sorry I'm a little vague now on the detail but I was looking at various solutions at the time.

  • Jason Espin 368 posts 1335 karma points
    Jun 22, 2015 @ 12:50
    Jason Espin
    0

    Okay for me this isn't working. I've added the UmbracoValidationAttributes package to my solution and added a reference to it in my site. Now however, when I build or try to run the overall solution it won't compile because it says namespaces and references are missing in the UmbracoValidationAttributes project. Any ideas?

  • Jason Espin 368 posts 1335 karma points
    Jun 22, 2015 @ 13:11
    Jason Espin
    0

    Okay I can confirm that this definitely is not working. I have now tried importing the files for this into my App_Code folder and setting each file to compile.

    I then rebuild my solution. After doing so I create a dictionary item to be used called:

    Validation.Required
    

    I then decorate my model with the following:

    public class TourInstanceSelection
        {
            [UmbracoRequired("Validation.Required")]
            public int? InstanceId { get; set; }
        }
    

    The message I set in the back office for this language is :

    Dis field is required!
    

    Instead, the error message I am getting is:

    The InstanceId field is required.
    
  • Craig Cronin 304 posts 503 karma points
    Jun 22, 2015 @ 14:40
    Craig Cronin
    1

    Hi Jason,

    I'm currently still working on our corporate site. I've just checked and its 7.2.4 and all is working fine.

    I've complied the dll and its in the bin folder but your example above is working fine with me. Send me your email address and I will email you the dll and source I'm using if its any different?

  • Jason Espin 368 posts 1335 karma points
    Jun 22, 2015 @ 15:05
    Jason Espin
    0

    So you are just dropping the compiled.dll of the project into your overall solution and not referencing the project? Doesn't this play hell with your dependencies? Is there any way I can just reference the project by adding it into my solution? I am using version 7.2.4.

    The other potential issue (although it shouldn't be) is my model is inheriting from RenderModel.

  • Jason Espin 368 posts 1335 karma points
    Jun 22, 2015 @ 15:08
    Jason Espin
    0

    My Email is [email protected]. Thanks for your help btw.

Please Sign in or register to post replies

Write your reply to:

Draft