Skip to content

FormBuilder and Tabbed/Paged forms #1426

Open
@divan

Description

@divan

Is there an existing issue for this?

  • I have searched the existing issues

Package/Plugin version

9.4.1

Platforms

  • Android
  • iOS
  • Linux
  • MacOS
  • Web
  • Windows

Flutter doctor

Flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.1, on macOS 14.5 23F79 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.1)
[✓] VS Code (version 1.86.1) - but I use vim

Minimal code example

FormBuilder(
      key: _formKey,
      initialValue: widget.initialValues,
      autovalidateMode: AutovalidateMode.disabled,
      child: DefaultTabController(
      length: 2,
      child: Scaffold(
        appBar: AppBar(
          bottom: const TabBar(
            tabs: myTabs,
          ),
        ),
        body: TabBarView(
          children: myTabs.map((Tab tab) {
            return _buildFieldsForTab(tab);
          }).toList(),
        ),
      ),
    );

Current Behavior

The issue is well described here: #462

As form grows, it's natural to split fields into few tabs/pages. As soon as it's happens (using default Flutter widgets), fields in the "hidden" tabs/pages aren't initialized. When form is submitted, these fields are absent, which is incorrect behavior.

Expected Behavior

There is a solution to use tabbed forms with FormBuilder.

It's more likely could be another way to initialize fields with initial values.

Steps To Reproduce

Run code as described

Aditional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    Status

    Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions