flutter-form-builder-ecosystem / flutter_form_builder

Simple form maker for Flutter Framework
https://pub.dev/packages/flutter_form_builder
MIT License
1.48k stars 535 forks source link

Add form grid #1189

Closed lukehutch closed 12 months ago

lukehutch commented 1 year ago

Environment

Package version: 7.7.0

Description

What you'd like to happen:

I need to build a form as a grid with three columns:

It would look like this

Option Choose one Choose multiple
Option 1
Option 2
Option 3
Option 4

Alternatives you've considered:

I don't see any way to build this using the current API. It would be great to have some sort of grid form element that would allow a user to do this. Then they should be able to associate a radio group or checkbox group with a row or column.

deandreamatias commented 1 year ago

Currently this package don't offer support for this. I don't sure about implement this feature in the feature, because is a widget that you can build manually, with one FormBuilderRadio or FormBuilderCheckbox for row or using FormBuilderRadioGroup FormBuilderCheckboxGroup

freemansoft commented 1 year ago

I am piling on to someone else's question here.

I spent a couple of hours looking at this and can't see how to insert any widgets between the FormBuilderCheckboxGroup and a bunch of FormBuilderFieldOption elements lay them into a table or grid.

FormBuilderCheckboxGroup
├── FormBuilderFieldOption
├── FormBuilderFieldOption
├── FormBuilderFieldOption
└── FormBuilderFieldOption

It sounds like you might be suggesting

FormBuilderCheckboxGroup
├── Some other container widget
│   └── FormBuilderCheckbox 
├── Some other container widget
│   └── FormBuilderCheckbox 
└── Some other container widget
    └── FormBuilderCheckbox 

There is some coordination between the FormBuilderChekcboxGroup and the FormBuilderFieldOption Is there any functionality lost if you create random FormBuilderCheckbox down graph from the FormBuilderCheckboxGroup?

If not then why does the FormBuilderFieldOption exist? To simplify layout?

freemansoft commented 1 year ago

Looking in the code....

It looks like the FormBuilderCheckboxGroup actually builds

Each option is

I don't see any of that in the widget inspector when actually running an app.

freemansoft commented 1 year ago

Assuming I understand the original question is actually two co-mingled FormBuilderCheckboxGroup constructs which seems complicated. It would require some kind of tagging with FormBuilderCheckbox looking up the tree to the nearest .

Providing a table layout for a single FormBuilderCheckboxGroup might be as simple as another orientation with a number of columns.

deandreamatias commented 1 year ago

With this comments, I think that the better option is create the own FormBuilderCheckboxGroup with table layout. From Flutter Form Builder Ecosystem, we can help to answer the questions about build but we won't create or modify the currently widget to offer support to this layout. Is something hard to maintain

freemansoft commented 1 year ago

You are suggesting to subclass (or wrap) FormBuilderCheckboxGroup and override the build() method to do the Grid/Table layout. It could use all the other utility methods do do the individual item/cell layout. Is that correct?

Another option is to convert OptionsOrientation into an interface that includes a function that is used to render the group. The current switch statement in FormBuilderCheckboxGroup for OptionsOrientation.horizontal, etc would then just invoke a known method on the OptionsOrientation interface. The current horizontal, vertical, etc would move from being enums to instances that implement the interface. This would let people plug in arbitrary orientations in the future and remove the funky hard coded layout currently in the FormBuilderCheckboxGroup build() method.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 12 months ago

This issue was closed because it has been stalled for 7 days with no activity.