Class: Forma::SubformField

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

Overview

Subform!

Instance Attribute Summary collapse

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, #url, #value, #width

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

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 = {}) ⇒ SubformField

Returns a new instance of SubformField.



263
264
265
266
267
# File 'lib/forma/field.rb', line 263

def initialize(h = {})
  h[:label] = false
  @form = Form.new(collapsible: true)
  super(h)
end

Instance Attribute Details

#formObject (readonly)

Returns the value of attribute form.



261
262
263
# File 'lib/forma/field.rb', line 261

def form
  @form
end

Instance Method Details

#edit_element(val) ⇒ Object



269
270
271
272
# File 'lib/forma/field.rb', line 269

def edit_element(val)
  init_forma_before_field_display(true)
  @form.to_html
end

#view_element(val) ⇒ Object



274
275
276
277
# File 'lib/forma/field.rb', line 274

def view_element(val)
  init_forma_before_field_display(false)
  @form.to_html
end