Class: Aurita::GUI::Input_Field

Inherits:
Form_Field show all
Defined in:
lib/aurita-gui/form/input_field.rb

Overview

Factory for input fields. Default type is :text, accoring to W3C, possible types are :password, :radio, :checkbox.

For radio and checkbox input fields, there are classes Radio_Field and Checkbox_Field, providing more convenience than building option fields manually. See also Options_Field on this topic.

Usage:

i = Input_Field.new(:type => :text, 
                    :name => :description, 
                    :label => 'Enter a discription', 
                    :value => 'Lorem ipsum dolor')

Direct Known Subclasses

Password_Field, Text_Field

Instance Attribute Summary

Attributes inherited from Form_Field

#form, #label, #type, #value

Attributes inherited from Element

#attrib, #content, #parent, #tag, #type

Instance Method Summary collapse

Methods inherited from Form_Field

#disable!, #editable!, #enable!, #readonly!, #readonly?, #readonly_element, #to_s

Methods inherited from Element

#+, #[], #[]=, #clear_floating, #dom_id, #dom_id=, #each, #empty?, #id, #id=, #length, #method_missing, #string, #to_ary

Constructor Details

#initialize(params, &block) ⇒ Input_Field

Returns a new instance of Input_Field.



25
26
27
28
29
30
31
32
# File 'lib/aurita-gui/form/input_field.rb', line 25

def initialize(params, &block)
  params[:tag]  = :input
  params[:type] = :text unless params[:type]
  if block_given? then
    params[:value] = yield
  end
  super(params)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Aurita::GUI::Element

Instance Method Details

#elementObject



33
34
35
# File 'lib/aurita-gui/form/input_field.rb', line 33

def element
  HTML.input(@attrib)
end