Class: Forma::TableField

Inherits:
SimpleField show all
Defined in:
lib/forma/field.rb

Overview

Table field.

Instance Attribute Summary

Attributes inherited from Field

#actions, #after, #autofocus, #before, #child_model_name, #height, #hint, #i18n, #icon, #inline_hint, #label, #model, #model_name, #name, #parent, #readonly, #required, #tag, #turbolink, #url, #value, #width

Instance Method Summary collapse

Methods inherited from SimpleField

#errors, #has_errors?, #value

Methods inherited from Field

#action, #id, #localization_key, #localized_hint, #localized_label, #name_as_chain, #parameter_name, #to_html

Methods included from Html

attr, el

Methods included from Utils

extract_value, number_format, #simple_value, singular_name

Constructor Details

#initialize(h = {}) ⇒ TableField

Returns a new instance of TableField.



506
507
508
509
510
511
512
# File 'lib/forma/field.rb', line 506

def initialize(h={})
  h = h.symbolize_keys
  h[:label] = false
  h[:force_nonempty] = true
  @table = Forma::Table.new(h[:table] || {})
  super(h)
end

Instance Method Details

#edit_element(val) ⇒ Object



519
520
521
# File 'lib/forma/field.rb', line 519

def edit_element(val)
  el('div', text: 'NO IMPLEMENTATION')
end

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

Yields:



523
524
525
526
# File 'lib/forma/field.rb', line 523

def table
  yield @table if block_given?
  @table
end

#view_element(val) ⇒ Object



514
515
516
517
# File 'lib/forma/field.rb', line 514

def view_element(val)
  @table.models = val
  @table.to_html
end