Skip to content

Commit

Permalink
fix: update form and validation data on sync
Browse files Browse the repository at this point in the history
When `initialValue` is set in the annotations, the value is passed to the
controller but is not added to the `formValueMap`. With this behavior cannot
be submitted or validated properly. To avoid this situation we update
the form data when view is synced with viewmodel.

In addition, if `autoTextFieldValidation` is true, we also update the
validation data.
  • Loading branch information
ferrarafer committed Jul 31, 2023
1 parent 548922e commit d576843
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/src/generators/forms/form_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ class FormBuilder with StringBufferUtils {
'${_getControllerName(field)}.addListener(() => _updateFormData(model));',
);
}

newLine();
writeLine(
"_updateFormData(model, forceValidate: _autoTextFieldValidation);",
);
writeLine('}');
newLine();

Expand All @@ -251,6 +256,11 @@ class FormBuilder with StringBufferUtils {
'${_getControllerName(field)}.addListener(() => _updateFormData(model));',
);
}

newLine();
writeLine(
"_updateFormData(model, forceValidate: _autoTextFieldValidation);",
);
writeLine('}');
newLine();
return this;
Expand Down

0 comments on commit d576843

Please sign in to comment.