Class: C2::Informant::FormElement

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document
Defined in:
app/models/c2/informant/form_element.rb

Instance Method Summary collapse

Instance Method Details

#as_json(options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/models/c2/informant/form_element.rb', line 17

def as_json(options={})
  {
    'type' => 'div',
    'id' => "entry_#{name}_field",
    'class' => "field #{name}_field #{tag}",
    'elements' => [
      {
        'type' => tag,
        'name' => name,
        'id' => "entry_#{name}",
        'class' => "#{name}_input #{tag}",
        'caption' => (caption || name.titleize)
      },
      {
        'type' => 'div',
        'class' => 'tip',
        'elements' => [
          {
            'type' => 'p',
            'html' => tip
          }
        ]
      }
    ]
  }
end