0 Replies Latest reply on Sep 17, 2013 7:29 PM by olegkon

    Validating dynamic form

    olegkon Level 1

      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.