SwiftyFORM icon indicating copy to clipboard operation
SwiftyFORM copied to clipboard

Is it possible to change form dynamically depends from user choice?

Open andrewSvsg opened this issue 8 years ago • 4 comments

For example user switch On/Off some option and and new section with some content will occur/hide in the current table

andrewSvsg avatar Apr 16 '16 12:04 andrewSvsg

There is no way to do this, yet. However it can be implemented fairly easy.

First modify the FormBuilder class with the desired functions.

Next modify the FormViewController class and perhaps other classes.

neoneye avatar Apr 16 '16 13:04 neoneye

Need this too so working on solution

justdan0227 avatar Jul 20 '21 17:07 justdan0227

so I tried to add: (removing a form item if segment 0 is selected in a segmentedControl

public func removeInnerItem(_ item: FormItem) {
        if let found = innerItems.firstIndex(where: {$0.elementIdentifier == item.elementIdentifier}) {
            innerItems.remove(at: found)
        }
            
    }

and added a elementIdentifier. However I can't get the form to reload like it would with tableview.reloadData()

instance.valueDidChangeBlock = {[weak self] (value: Int) in
            print (value)
            if value == 0 {
                self?.mainBuilder.removeInnerItem(self!.venueListFormItem)
                self?.mainBuilder.validateAndUpdateUI()
            }
        }

justdan0227 avatar Jul 20 '21 17:07 justdan0227

The form cannot insert/remove fields dynamically. I can't recall why I said it was easy to make. I think nowadays it's non-trivial to code.

neoneye avatar Jul 21 '21 09:07 neoneye