Skip to content

How to dynamically assign rows to Formotion table #237

@orbitalmedia

Description

@orbitalmedia

I have a large form that I want to break up into subforms - I'm attempting to do this dynamically - does anyone know if this sort of thing is possible? Flat forms are fine, but I get a error when attempting to add the subform

*** Terminating app due to uncaught exception 'TypeError', reason: 'wrong argument type Class (expected Module) (TypeError)

Has anyone an idea of what this issue is? The to_form_hash appears to take a collection of Formotion::Row

Thanks,

An example of what I'm trying..

class PropertyItem
  include Formotion::Formable
  include Formotion::Row
  PROPERTIES = [:id, :name, :streetno, :street_name]
  @rows = ().to_a
  PROPERTIES.each { |prop|
    attr_accessor prop
    p prop
   if prop.include? "street_no" or prop.include? "street_name"
        row = Formotion::Row.new
        row.title = prop
        row.type = :string      
        @rows << row    
   elsif
       form_property prop, :string
    end
  }
  form_property :address, :subform, subform: {title: "Address", sections: [{title: "Address", rows:[@rows]}]}  

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions