infinitered / ProMotion-form

Deprecated -- use ProMotion-XLForm
19 stars 11 forks source link

subform support #39

Closed neilma closed 8 years ago

neilma commented 9 years ago

Correct me if I'm wrong, subform (not option) doesn't seem to be supported like formotion does it?

e,g, https://github.com/clayallsopp/formotion/wiki/List-of-all-the-row-types#picker

jamonholmgren commented 9 years ago

FXForms does support subforms, but I haven't built in an affordance for them into ProMotion-form yet. Would you want to help do that? :)

There is a ton more functionality in FXForms we can tap into and give a sane RubyMotion-esque API. FXForms' API leaves a lot to be desired, and the longform documentation is difficult to understand.

neilma commented 9 years ago

Read a lot of your docos, great stuff, you are everywhere. I'm happy to give it a shot. I just started using promotion.

What I'm trying to achieve is that clicking on a form option (button if not subform) and it goes to another screen which shows a few sliders, navigating back to the form carries over the sliders' values and update the form values presented on screen.

Without subform for now, how would you implement the above scenario? I'm thinking about passing render_form data in attr_accessor between screens, but would love to know if there is a better workaround.

jamonholmgren commented 9 years ago

Great! For now, you could just open a new tablescreen, and implement an action like this:

class SelectorScreen < PM::TableScreen
  title "Select something"

  def table_data
    [{
      cells: [
        { title: "Option 1", action: :select, arguments: 1 },
        { title: "Option 2", action: :select, arguments: 2 },
        { title: "Option 3", action: :select, arguments: 3 },
      ]
    }]
  end

  def select(arg)
    close selected: arg
  end
end

In your original form screen:

def on_return(result={})
  if result[:selected]
    # do something with it?
  end
end
neilma commented 9 years ago

Brilliant, and if i want to update one of the cells in the original screen, should I use update_form_data which might be expensive since I'm only looking to update one cell value.

Or I'll need to somehow find the cell and update it?

My current solution (correct me if there is a better way): original form has an instance var @nav_data which keeps the data from render_form().

def on_return(opts={})
  @nav_data[:key] = opts[:key]
  update_form_data
end

def form_data
  [{value: "#{nav_data[:key]}"}]
end
jamonholmgren commented 9 years ago

update_form_data is pretty fast, so go for it! Your solution looks good.

neilma commented 9 years ago

is there a way to set row height to auto with an estimate like for table? I'm trying to make my custom cell expand as the content grows.

jamonholmgren commented 9 years ago

Not yet, unfortunately.

jamonholmgren commented 8 years ago

ProMotion-form has been officially deprecated. Thanks everyone!

http://jamonholmgren.com/deprecating-promotion-form/