Last active
August 29, 2015 14:25
-
-
Save bmichotte/29749f1d73d626537117 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestFormScreen < PM::FormScreen | |
title "PM::XLFormScreen" | |
form_options required: :asterisks, | |
# by default, button "title" is NSLocalizedString("Save") | |
on_save: :'save_form:', | |
# or | |
on_cancel: { action: :cancel_form, item: :cancel, title: "Cancel" } | |
def form_data | |
[ | |
{ | |
title: 'Account information', | |
footer: 'Some help text', | |
cells: [ | |
{ | |
title: 'Email', | |
name: :email, | |
type: :email, | |
placeholder: 'Enter your email', | |
required: true | |
}, | |
{ | |
title: 'Name', | |
name: :name, | |
type: :text | |
}, | |
{ | |
title: 'Yes ?', | |
name: 'check', | |
type: :switch | |
}, | |
{ | |
title: 'Options', | |
name: 'options', | |
type: :selector_push, | |
options: { | |
"value_1" => "Value 1", | |
"value_2" => "Value 2", | |
"value_3" => "Value 3", | |
"value_4" => "Value 4", | |
}, | |
value: "value_1", | |
on_change: lambda {|old_value, new_value| | |
puts "#{old_value} has been changed to #{new_value}" | |
} | |
} | |
] | |
}, | |
{ | |
cells: [ | |
{ | |
title: 'A slider', | |
name: :slider, | |
type: :slider, | |
properties: { | |
max: 100, | |
min: 2, | |
step: 4 | |
} | |
}, | |
{ | |
title: 'A date', | |
name: :date, | |
type: :date_inline | |
}, | |
{ | |
title: 'Another date', | |
name: :other_date, | |
type: :date_inline, | |
properties: { | |
min: NSDate.new | |
} | |
}, | |
{ | |
title: 'An image', | |
name: :picture, | |
type: :image | |
} | |
] | |
}, | |
{ | |
title: 'Multi-value', | |
name: 'multi', | |
options: [:insert, :delete, :reorder], | |
cells: [ | |
{ | |
title: 'Some text', | |
name: :some_text, | |
type: :text | |
} | |
] | |
} | |
] | |
end | |
def save_form(values) | |
mp on_save: values | |
end | |
def cancel_form | |
mp 'cancel_form has been called' | |
end | |
end |
Author
bmichotte
commented
Jul 21, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment