Class: HtmlCom::Form

Inherits:
Element show all
Defined in:
lib/htmlcom.rb

Instance Method Summary collapse

Methods inherited from Element

#build, #html_element, #to_doc, #to_html

Constructor Details

#initialize(inputs = nil, id: nil, method: :get, action: '') ⇒ Form

Returns a new instance of Form.



436
437
438
439
440
441
442
443
444
445
446
447
448
# File 'lib/htmlcom.rb', line 436

def initialize(inputs=nil, id: nil, method: :get, action: '')

  @tag = 'form'
  @htmltag = 'form'
  @id = id

  super([:root, {}, [@tag,{}, [@htmltag, {}]]])
  form = @doc.root.element(@tag + '/' + @htmltag)
  form.add inputs if inputs
  form.attributes[:method] = method.to_s
  form.attributes[:action] = action

end

Instance Method Details

#add_submitObject



450
451
452
453
# File 'lib/htmlcom.rb', line 450

def add_submit()
  submit = Rexle.new(['input', {type: 'submit', value: 'Submit'}])
  html_element().add submit
end