-
-
Notifications
You must be signed in to change notification settings - Fork 561
feat nested_form_builder.dart add NestedFormBuilder; #1156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
feat nested_form.dart NestedForm add NestedFormBuilder Demo
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@ ## main #1156 +/- ## ========================================== - Coverage 84.93% 82.22% -2.72% ========================================== Files 19 20 +1 Lines 697 720 +23 ========================================== Hits 592 592 - Misses 105 128 +23 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I just came to issues looking for a way to nest forms, appreciate this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 more things to review:
- Revert pubspec.lock changes
- Add tests (can be minimal) to NestedFromBuilder
- Add how use nested builder to README.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace this line with language config, like this:
supportedLocales: [ Locale('de'), Locale('en'), Locale('es'), Locale('fr'), Locale('it'), ... ],
Thanks a lot for this contribution! Will be a big step foward to improve this package.
Because this is a new important feature, required some changes to can be stable and easy to use for all
k-ane
commented
Jan 7, 2023
Hi, I have been testing this new feature (it's awesome btw, thanks for the PR) and I was wondering how validation will work? For me right now, validating the parent/main form didn't trigger validation on the nested/child fields.
k-ane
commented
Jan 7, 2023
I got the nested form validation to work for me by adding a validator to the FormBuilderField of NestedFormBuilder, like so:
@override Widget build(BuildContext context) => FormBuilderField<Map<String, dynamic>>( name: name, initialValue: parentFormKey?.currentState?.initialValue[name] ?? initialValue, valueTransformer: valueTransformer ?? (_) => _, onReset: () => formKey.currentState?.reset(), // Added validator here validator: (_) => (formKey.currentState?.validate() ?? false) ? null : '', builder: (field) => FormBuilder( key: formKey, initialValue: field.value ?? {}, onChanged: () { final st = formKey.currentState; if (st == null) return; st.save(); field.didChange(valueTransformer?.call(st.value) ?? st.value); }, autovalidateMode: autovalidateMode, onWillPop: onWillPop, skipDisabled: skipDisabled, enabled: enabled, autoFocusOnValidationFailure: autoFocusOnValidationFailure, clearValueOnUnregister: clearValueOnUnregister, child: child, ), );
k-ane
commented
Jan 8, 2023
Something else worth noting, I had to add
autovalidateMode: autovalidateMode,just below the new validator, otherwise the nested form was validating on every change. Previously the autovalidateMode was only being passed to the FormBuilder and not the FormBuilderField component
mfizz1
commented
Aug 25, 2023
Any update on this? This is such a game changer that is desperately needed.
letto4135
commented
Dec 10, 2023
Ready for nested forms 👍
Arpit1496
commented
Jan 30, 2024
any update on this ?
UsamaKarim
commented
Apr 19, 2024
It doesn't seem to solve all use cases, for example, if I have a nested list,
{
"foo": "foo value0",
"inner": [
{
"bar": "bar value1",
"baz": "baz value2"
},
{
"bar": "bar value1",
"baz": "baz value2"
}
]
}
mustafamasri1
commented
Jan 24, 2025
any updates?
any updates?
@mustafamasri1 can follow the new features here: #1466
Also, can support the package development here: https://opencollective.com/flutter-form-builder-ecosystem
Uh oh!
There was an error while loading. Please reload this page.
Add NestedFormBuilder and some example code
resolve issue #239 and #1117
{ "foo": "foo value0", "inner": { "bar": "bar value1", "baz": "baz value2", } }