Class: Dima::Html::ComplexField

Inherits:
Field show all
Defined in:
lib/dima/html/field.rb

Overview

Complex field.

Instance Attribute Summary collapse

Attributes inherited from Field

#after, #align, #before, #edit, #form, #has_errors, #hint, #label, #required, #tooltip, #url

Instance Method Summary collapse

Methods inherited from Field

#after_node, #before_node, #edit?, #empty_node, #label_node, #options, #to_n, #url_node, #val, #val=, #validate, #value_node

Methods included from Init

#initialize

Methods inherited from Element

#id, #id=

Instance Attribute Details

#modelObject

Returns the value of attribute model.



200
201
202
# File 'lib/dima/html/field.rb', line 200

def model
  @model
end

Instance Method Details

#<<(v) ⇒ Object

Initialize this field from a model.



208
209
210
211
212
213
# File 'lib/dima/html/field.rb', line 208

def << (v)
  self.model = v
  fields.each do |f|
    f << v
  end
end

#>>(v) ⇒ Object



215
216
217
# File 'lib/dima/html/field.rb', line 215

def >> (v)
  fields.each { |f| f >> v }
end

#empty?Boolean

Returns:

  • (Boolean)


219
220
221
222
223
224
# File 'lib/dima/html/field.rb', line 219

def empty?
  fields.each do |f|
    return false unless f.empty?
  end
  true
end

#fieldsObject

fields for this component.



203
204
205
# File 'lib/dima/html/field.rb', line 203

def fields
  @fields ||= []
end

#main_content_nodeObject



226
227
228
229
230
231
232
233
# File 'lib/dima/html/field.rb', line 226

def main_content_node
  cmplx = Node.new(tag: 'div', attributes: { class: 'dim-complex' })
  fields.each do |f|
    f.edit = self.edit
    cmplx << f.main_content_node unless f.empty?
  end
  cmplx
end