Class: Campo::Input
Overview
form << Campo::Input.new( “submit”, :submit )
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Attributes included from Childish
Instance Method Summary collapse
-
#initialize(name, type = :text, attributes = {}) ⇒ Input
constructor
{ type: nil, value: nil, name: nil } { size: nil, maxlength: nil, type: “text” } { size: nil, maxlength: nil, type: “hidden” } { type: “submit” }.
Methods inherited from Base
#labelled, #on_output, #output, output, quotable, unhash
Methods included from Convenience
#bit_of_ruby, #checkbox, #fieldset, #input, #literal, #radio, #select, #submit, #text, #textarea
Methods included from Iding
Methods included from Childish
Constructor Details
#initialize(name, type = :text, attributes = {}) ⇒ Input
{ type: nil, value: nil, name: nil } { size: nil, maxlength: nil, type: “text” } { size: nil, maxlength: nil, type: “hidden” } { type: “submit” }
439 440 441 442 443 444 445 446 447 448 449 450 451 452 |
# File 'lib/campo.rb', line 439 def initialize( name, type=:text, attributes={} ) super( name, { type: type.to_s, id: "#{name}#{id_tag(attributes[:value]).gsub(/\W/, "_")}", tabindex: %q!#{i += 1}!, }.merge( attributes ) ) @attributes.delete(:name) if type == :submit self.on_output do |n=0, tab=2| %Q!#{" " * n * tab}%input{ atts[:#{name.gsub(/\W/, "_")}#{id_tag(attributes[:value]).gsub(/\W/, "_")}], #{Base.unhash( @attributes )} }! end end |