0

I have a settings screen that works quite nicely using the "ProMotion-formotion" gem. I would like to make a couple of the rows into buttons that will call a method when pressed eg:

  def table_data
    set_nav_bar_button :left, title: "Cancel", action: :close
    set_nav_bar_button :right, title: "Save", action: :submit

    {sections:[{
      title: 'Help',
      rows: [{
        title: "About",
        type: :string,
        editable: false,
        action: :help  #this is the sort of thing I want
      }]
    }, {
      title: 'General',
      rows: [
[...etc...]

Anyone know how I can achieve this?

edit: I've found a possible solution here: How to use .on_delete callback in ProMotion-Formotion

But still wondering if there is a way of doing it within the table_data method.

Community
  • 1
  • 1
jjnevis
  • 2,672
  • 3
  • 22
  • 22

1 Answers1

0

Figured it out...

{
  title: "Any Button",
  type: :button,
  key: :some_button
}

# later...
form.row(:some_button).on_tap do |row|
  # do something when tapped
end

from here: https://github.com/clayallsopp/formotion/blob/master/LIST_OF_ROW_TYPES.md#button

jjnevis
  • 2,672
  • 3
  • 22
  • 22