Class: Lapillus::FormComponent

Inherits:
Component show all
Defined in:
lib/lapillus/form_components.rb

Direct Known Subclasses

FileUploadField, FormTextComponent

Instance Attribute Summary

Attributes inherited from Component

#behaviours, #identifier, #model, #property, #visible

Instance Method Summary collapse

Methods inherited from Component

#add_behaviour, #behaviour, #has_behaviour?, #has_model?, #has_parent?, #initialize, #on_render, #parent, #path, #render_component, #response_page=, #session, #visible?, #webpage

Constructor Details

This class inherits a constructor from Lapillus::Component

Instance Method Details

#post(values) ⇒ Object



5
6
7
# File 'lib/lapillus/form_components.rb', line 5

def post(values)
  self.value=values[path] if values.has_key?(path)
end

#render_to_element(element) ⇒ Object



9
10
11
# File 'lib/lapillus/form_components.rb', line 9

def render_to_element(element)
  element.attributes['name'] = path
end

#valueObject



12
13
14
15
16
# File 'lib/lapillus/form_components.rb', line 12

def value
  return super if has_model?
  return parent.model.send(identifier) if parent.has_model?
  raise "model not set!"
end

#value=(new_value) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/lapillus/form_components.rb', line 18

def value=new_value
  if property.nil?
    @model=new_value
  else
    model.send(property.to_s+"=", new_value)
  end
end