You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using a form view widget in stacked. I would like to dynamically set the initial value of a text field based on the props passed to the component, thus I cannot use the initialValue property inside the FormView decorator. My current approach is to accept an object containing the form values inside of my constructor of the view model and set the form values. However, this does not updating my text fields with the correct values.
To reproduce
Inside of my form's view model's constructor, I'm accepting the object containing the form's values and setting those.
SetTourInfoModel(Tour tour) {
titleValue = tour.title;
descriptionValue = tour.description;
rebuildUi(); // not sure if this is necessary but included it for the sake of completeness.
}
and I call this function inside the widget like:
@overrideSetTourInfoModelviewModelBuilder(
BuildContext context,
) =>SetTourInfoModel(initialTour); // where initialTour is a variable passed into widget's constructor
Expected behavior
This should set the form's text field values to be the ones described in the Tour object I'm passing to my view model.
Screenshots
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered:
This was user error. Instead of setting the values in the view model's constructor I'm calling an initFormValues inside the onViewModelReady function and setting the form values there. It might be helpful to document this process on the docs as the existing docs on forms is extremely simplistic. I look forward to the "deep dive of Stacked Forms" coming soon!
Describe the bug
I am using a form view widget in stacked. I would like to dynamically set the initial value of a text field based on the props passed to the component, thus I cannot use the
initialValue
property inside theFormView
decorator. My current approach is to accept an object containing the form values inside of my constructor of the view model and set the form values. However, this does not updating my text fields with the correct values.To reproduce
Inside of my form's view model's constructor, I'm accepting the object containing the form's values and setting those.
and I call this function inside the widget like:
Expected behavior
This should set the form's text field values to be the ones described in the
Tour
object I'm passing to my view model.Screenshots
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: