class Formotion::FormController
Attributes
form[RW]
Public Instance Methods
form=(form)
click to toggle source
Set the form; ensure it is/can be converted to Formotion::Form
or raises an exception.
# File lib/formotion/controller/form_controller.rb, line 28 def form=(form) if form.is_a? Hash form = Formotion::Form.new(form) elsif not form.is_a? Formotion::Form raise Formotion::InvalidClassError, "Attempted FormController.form = #{form.inspect} should be of type Formotion::Form or Hash" end @form = form end
initWithForm(form)
click to toggle source
Initializes controller with a form PARAMS form.is_a? [Hash, Formotion::Form] RETURNS An instance of Formotion::FormController
# File lib/formotion/controller/form_controller.rb, line 17 def initWithForm(form) self.initWithStyle(UITableViewStyleGrouped) self.form = form #self.view.setEditing true, animated: true self.tableView.allowsSelectionDuringEditing = true self end
pop_subform()
click to toggle source
# File lib/formotion/controller/form_controller.rb, line 72 def pop_subform if self.navigationController self.navigationController.popViewControllerAnimated true else self.dismissModalViewControllerAnimated true end end
push_subform(form)
click to toggle source
Subview Methods
# File lib/formotion/controller/form_controller.rb, line 62 def push_subform(form) @subform_controller = self.class.alloc.initWithForm(form) if self.navigationController self.navigationController.pushViewController(@subform_controller, animated: true) else self.presentModalViewController(@subform_controller, animated: true) end end
viewDidLoad()
click to toggle source
Calls superclass method
# File lib/formotion/controller/form_controller.rb, line 37 def viewDidLoad super # Triggers this block when the enter key is pressed # while editing the last text field. @form.sections[-1] && @form.sections[-1].rows && @form.sections[-1].rows[-1] && @form.sections[-1].rows[-1].on_enter do |row| if row.text_field @form.submit row.text_field.resignFirstResponder end end # Setting @form.controller assigns # @form as the datasource and delegate # and reloads the data. @form.controller = WeakRef.new(self) end
viewWillAppear(animated)
click to toggle source
Calls superclass method
# File lib/formotion/controller/form_controller.rb, line 55 def viewWillAppear(animated) super self.tableView.reloadData end