Skip navigation
Currently Being Moderated

Validating dynamic form

Sep 17, 2013 7:29 PM

Tags: #4.5 #actionscript #form #required #validation #spark_datagrid

I have a Spark DataGrid with data dynamically populated from the database,

so I don't know column count or names.

I need to Add/Edit that data, which I do pulling selected row for edit in dynamic form.

Some of the values on that form are required (extra attribute in DataProvider).

 

So I need to do required validation of that dynamically built form.

Using Flex 4.5.1

 

I tried the following:

private function validateRequiredField(field:TextInput):void {

 

var validator:StringValidator = new StringValidator();

validator.source = "{field}";     <<< Error: source attribute "{field}" can not be of Type String [from mx.validators::Validator/set]

validator.property = "text";

validator.requiredFieldError = "This field is required";

validators.push(validator);

}

 

Any idea why I am getting that error above?

I am passing Spark's TextInput control there, not a String.

Calling it in "for" loop going through Dictionary of TextInput object, where Key is column name.

 

How can I fix it?

 

TIA,

Oleg.

 

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points