View Full Version : [CLOSED] Field Errors help

Aug 15, 2013, 4:40 PM
Just in case someone recognizes this and/or knows off hand what I need to include in order to fix this, I'm not putting full sample code in yet. If a sample is needed I will post it.

I am using MVC Razor.

I was following the Models > Submit example (http://mvc.ext.net/#/Models/Submit/) for displaying validation messages that come back from a data service. I have parsed the message and successfully filled a FieldErrors collection. Here is some of the code I'm using:

.FieldDefaults(def =>
def.MsgTarget = MessageTarget.Side;
.DirectEvents(de =>
de.Click.Url = Url.Action("Submit");
de.Click.EventMask.ShowMask = true;
de.Click.FormID = "Form1";
Html.X().TextFieldFor(m => m.Fund.ShortName).FieldLabel("Short Name"),
Html.X().TextFieldFor(m => m.Fund.LegalName).FieldLabel("Legal Name"),
Html.X().TextFieldFor(m => m.Fund.Cusip).FieldLabel("Cusip"),
Html.X().ComboBoxFor(m => m.Fund.FundStructure)
.FieldLabel("Fund Structure")
Html.X().StoreFor(m => m.FundStructures)

public ActionResult Submit(Fund fund)

try {
catch (DataServiceRequestException dse)
string fieldId;
string errorMessage;
var fieldErrors = new FieldErrors();


foreach (XElement error in errors)
fieldId = "Fund_" + error.Element("Field").Value;
errorMessage = error.Element("Error").Value;

fieldErrors.Add(new FieldError(fieldId, errorMessage));

return this.FormPanel(fieldErrors);

return this.Direct()

When the response is sent to the view, however, instead of marking the fields as invalid and showing the error message, I get this:

Again - in case it's something silly on my part, I'm posting without full code sample, but I will provide a full sample if needed.

Aug 15, 2013, 5:09 PM
You cannot use FormPanelResult for DirectEvent requests, FormPanelResult is designed for from requests only (requests are initiated by FormPanel, for example App.FormPanel1.submit(....))

In your case, DirectResult can be used only

Aug 15, 2013, 6:00 PM
How, then, do I mark the fields as invalid and populate the error message?

I tried:

var f = X.GetCmp(fieldId);

if (f is TextField) ((TextField)f).MarkInvalid(errorMessage);
else if (f is ComboBox) ((ComboBox)f).MarkInvalid(errorMessage);

But nothing happened. I watched in debug and var f was always null - even though the field id was correct. I assumed the ActionResult Submit didn't know about the form and so could not "get" the controls.

Aug 15, 2013, 7:11 PM
Need to use generic version of GetCmp

var field = X.GetCmp<TextField>(fieldId);

Aug 16, 2013, 6:17 PM
Thanks Vladimir. Oddly, using <TextField> works even for the ComboBox.

Aug 19, 2013, 2:52 PM
Thanks Vladimir. Oddly, using <TextField> works even for the ComboBox.

I have to *edit* that... it was working at first, but after restarting the app, the validation only works for the TextField controls.

Aug 19, 2013, 3:08 PM
Please post runable test sample reproduces the issue