Class: Formidable::Elements::Form

Inherits:
ElementList show all
Defined in:
lib/formidable/elements.rb

Constant Summary

Constants included from Rendering

Rendering::RendererNotAssigned

Instance Attribute Summary

Attributes inherited from BasicElement

#attributes, #cleaned_data, #content, #name, #raw_data, #tag

Attributes included from Rendering

#renderer

Instance Method Summary collapse

Methods inherited from ElementList

#cleaned_data, #content, #elements, #raw_data, #raw_data=, register, #set_prefix

Methods included from GroupValidations

#before_validate, #errors, register_validation, #valid?, #validate, #validations

Methods included from Rendering

included, #render

Constructor Details

#initialize(action, method = "POST", prefix = nil, attributes = Hash.new, raw_data = Hash.new) ⇒ Form

TODO: prefix should be in the form definition (name or namespace)



124
125
126
127
128
129
130
# File 'lib/formidable/elements.rb', line 124

def initialize(action, method = "POST", prefix = nil, attributes = Hash.new, raw_data = Hash.new)
  @raw_data = raw_data
  self.setup
  super(:form, nil, attributes.merge!(action: action, method: method), raw_data)
  set_prefix(prefix) if prefix
  self.raw_data = raw_data
end

Instance Method Details

#save(*args) ⇒ Object Also known as: save!

Raises:

  • (NotImplementedError)


136
137
138
# File 'lib/formidable/elements.rb', line 136

def save(*args)
  raise NotImplementedError, "You have to redefine this method in subclasses!"
end

#setupObject

Raises:

  • (NotImplementedError)


132
133
134
# File 'lib/formidable/elements.rb', line 132

def setup
  raise NotImplementedError, "You are supposed to redefine the setup method in subclasses of Element!"
end

#update(*args) ⇒ Object Also known as: update!

Raises:

  • (NotImplementedError)


141
142
143
# File 'lib/formidable/elements.rb', line 141

def update(*args)
  raise NotImplementedError, "You have to redefine this method in subclasses!"
end