BrianTheCoder-ratpack 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION.yml +1 -1
  2. data/lib/ratpack/forms.rb +15 -4
  3. metadata +2 -2
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 2
3
- :patch: 3
3
+ :patch: 4
4
4
  :major: 0
data/lib/ratpack/forms.rb CHANGED
@@ -11,7 +11,7 @@ module RatPack
11
11
  %w(text password hidden file).each do |kind|
12
12
  self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
13
13
  def #{kind}_field(attrs)
14
- attrs[:class] = "text" if %w(text password).include?("#{kind}")
14
+ attrs[:class] = "text" if %w(text password).include?("#{kind}") && !attrs.has_key?(:class)
15
15
  closed_form_field(:input, {:type => "#{kind}"}.merge(attrs))
16
16
  end
17
17
  RUBY
@@ -38,13 +38,17 @@ module RatPack
38
38
  end
39
39
 
40
40
  def check_box(attrs)
41
+ html = ""
42
+ label = build_field(attrs)
41
43
  if attrs.delete(:boolean)
42
44
  on, off = attrs.delete(:on), attrs.delete(:off)
43
- hidden_field(:name => attrs[:name], :value => off) <<
44
- closed_form_field(:input, {:type => "checkbox", :value => on}.merge(attrs))
45
+ html << hidden_field(:name => attrs[:name], :value => off)
46
+ html << self_closing_tag(:input, {:type => "checkbox", :value => on}.merge(attrs))
45
47
  else
46
48
  closed_form_field(:input, {:type => "checkbox"}.merge(attrs))
49
+ html << self_closing_tag(:input, {:type => "checkbox"}.merge(attrs))
47
50
  end
51
+ html + label
48
52
  end
49
53
 
50
54
  def select(attrs = {})
@@ -52,13 +56,20 @@ module RatPack
52
56
  form_field(:select, options_for(attrs), attrs)
53
57
  end
54
58
 
55
- def submit(value, attrs = {})
59
+ def submit(value="Submit", attrs = {})
56
60
  attrs[:type] ||= "submit"
57
61
  attrs[:name] ||= "submit"
58
62
  attrs[:value] ||= value
59
63
  closed_form_field(:input, attrs)
60
64
  end
61
65
 
66
+ def reset(value="Reset", attrs = {})
67
+ attrs[:type] ||= "reset"
68
+ attrs[:name] ||= "reset"
69
+ attrs[:value] ||= value
70
+ closed_form_field(:input, attrs)
71
+ end
72
+
62
73
  private
63
74
 
64
75
  def form_field(type, content, attrs)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: BrianTheCoder-ratpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - brianthecoder
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-12 00:00:00 -07:00
12
+ date: 2009-04-14 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15