XForm Required Field Validation Message

Vote:
 

Hi,

I have read some topics on customising XForm validation messages using the language files; which have been very useful.

My problem arises when trying to customise the Required Value attribute of an XForm field. I have the following XML in my language resource:

    <xform>
      <requirelogon>You need to be logged in</requirelogon>
      <requiredfield>
        <inlineerrormessage>Required Field</inlineerrormessage>
      </requiredfield>
      <datatypes>
        <integer>
          <inlineerrormessage>Not a valid integer</inlineerrormessage>
        </integer>
      </datatypes>
    </xform>

    

My custom integer message appears correctly but my issue is with the Required Field message, which only ever displays the message:

Value must be entered ("")

I have checked the XPath for the override and it matches that returned by the Localization Service as the default message, though the default message itself isn't returned even if I don't specify one.

I've searched my solution for similar strings to the error message shown and can find nothing. I am fresh out of ideas what could be causing this behaviour so any suggestions are welcome!

Cheers

#71807
May 29, 2013 17:58
Vote:
 

Actually Episerver 7 Xform Validation message is different from old versions, I found it by this path:

XPath : "/admin/editpropertydefinition/requiredcaption"

hopes some helpful to you.

#73897
Aug 14, 2013 5:35
Vote:
 

http://cjsharp.com/blog/2013/04/30/list-of-xform-system-localization-keys-in-episerver-7/

I think it is not correct for required field validation.

#73898
Aug 14, 2013 5:37
Vote:
 

Looking through the code it seems MVC uses a different message than web forms. MVC uses the path Martin mentioned ("/admin/editpropertydefinition/requiredcaption"). I'll report a bug for this since they should be the same and it's not recomended to override system messages. The temporary work around would be to override the system message until the bug has been fixed.

"/admin/editpropertydefinition/requiredcaption"

#73901
Aug 14, 2013 8:32
Vote:
 

Hi Linus,

About Required ErrorMessage, it always use string.format to mix two element: errormessage + ("Title")

If we could use xml or other method to override it , I think that would have a higher configurability.

We then could only return "This field is required" message instead of that one which include brackets and title.

#73902
Aug 14, 2013 8:41
Vote:
 

Thanks for the feedback Martin. Actually, for web forms have the behaviour suggested so I just made sure that it works in MVC as well. The solution is to get the translated resource for the key "/xform/requiredfield/summaryerrormessageformat". Then we do a String.Format and pass the title as the first parameter. This means that it's up to you to include or exclude the title in the message format, for instance:

"You need to fill in {0}"

or just

"Required field"

#73908
Aug 14, 2013 9:33
Vote:
 

So please report a bug and thanks, Linus.

#73910
Aug 14, 2013 9:48
Vote:
 

I reported and fixed the bug. For future reference, the bug is:

Bug #104343: MVC XForm validation uses a system localization message which should not be overridden by partners
#73916
Aug 14, 2013 11:12
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.