Class: Dima::Html::AbstractForm

Inherits:
Element
  • Object
show all
Includes:
Init
Defined in:
lib/dima/html/form.rb

Overview

Abstract form.

Direct Known Subclasses

Form, Table

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Init

#initialize

Methods inherited from Element

#id, #id=

Instance Attribute Details

#collapsedObject

Whether the form is collapsed?



16
17
18
# File 'lib/dima/html/form.rb', line 16

def collapsed
  @collapsed
end

#helpObject

Help text for this form.



14
15
16
# File 'lib/dima/html/form.rb', line 14

def help
  @help
end

#iconObject

Title icon.



12
13
14
# File 'lib/dima/html/form.rb', line 12

def icon
  @icon
end

#methodObject

Form method.



20
21
22
# File 'lib/dima/html/form.rb', line 20

def method
  @method
end

#submitObject

Submit button text.



18
19
20
# File 'lib/dima/html/form.rb', line 18

def submit
  @submit
end

#titleObject

Title for this form.



10
11
12
# File 'lib/dima/html/form.rb', line 10

def title
  @title
end

Instance Method Details

#actionsObject

Get form’s actions.



23
24
25
# File 'lib/dima/html/form.rb', line 23

def actions
  @actions ||= []
end

#htmlObject



27
28
29
30
31
32
33
# File 'lib/dima/html/form.rb', line 27

def html
  if defined?(Rails)
    to_n.html.html_safe
  else
    to_n.html
  end
end

#to_nObject



35
36
37
38
39
40
41
42
43
# File 'lib/dima/html/form.rb', line 35

def to_n
  node = Node.new(tag: 'div', attributes: { id: self.id, class: 'dim-form' })
  node << generate_title
  content = Node.new(tag: 'div', attributes: { class: 'dim-form-content' })
  content[:style] = 'display: none;' if self.collapsed
  content << generate_content
  node << content
  node
end