Class: Forma::Tab

Inherits:
Object
  • Object
show all
Includes:
FieldHelper
Defined in:
lib/forma/form.rb

Overview

This is a tab.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FieldHelper

#array_field, #boolean_field, #combo_field, #complex_field, #date_field, #email_field, #file_field, #image_field, #map_field, #number_field, #password_field, #select_field, #subform, #table_field, #text_field

Constructor Details

#initialize(h = {}) ⇒ Tab

Returns a new instance of Tab.



213
214
215
216
217
218
219
220
# File 'lib/forma/form.rb', line 213

def initialize(h = {})
  h = h.symbolize_keys
  @title = h[:title]
  @icon = h[:icon]
  @col1 = h[:col1]
  @col2 = h[:col2]
  @actions = h[:actions] || []
end

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions.



211
212
213
# File 'lib/forma/form.rb', line 211

def actions
  @actions
end

#iconObject (readonly)

Returns the value of attribute icon.



211
212
213
# File 'lib/forma/form.rb', line 211

def icon
  @icon
end

#titleObject (readonly)

Returns the value of attribute title.



211
212
213
# File 'lib/forma/form.rb', line 211

def title
  @title
end

Instance Method Details

#action(url, h = {}) ⇒ Object



241
242
243
244
# File 'lib/forma/form.rb', line 241

def action(url, h={})
  h[:url] = url
  @actions << Action.new(h)
end

#add_field(f) ⇒ Object

Adding field to this tab.



223
224
225
# File 'lib/forma/form.rb', line 223

def add_field(f)
  col1.add_field(f)
end

#col1 {|@col1| ... } ⇒ Object

Returns the first column of this tab.

Yields:



228
229
230
231
232
# File 'lib/forma/form.rb', line 228

def col1
  @col1 = Col.new if @col1.blank?
  yield @col1 if block_given?
  @col1
end

#col2 {|@col2| ... } ⇒ Object

Returns the second column of this tab.

Yields:



235
236
237
238
239
# File 'lib/forma/form.rb', line 235

def col2
  @col2 = Col.new if @col2.blank?
  yield @col2 if block_given?
  @col2
end