public
Description: A Ruby web application framework
Homepage: http://www.mackframework.com
Clone URL: git://github.com/markbates/mack.git
Click here to lend your support to: mack and make a donation at www.pledgie.com !
Adding rdoc for html form helpers.[#19]
markbates (author)
Thu Aug 14 12:37:41 -0700 2008
commit  53d126e181ab37c249b472a28201e0b3cf033db8
tree    079bab406c00f24547708fea5cc27cdb1a5a721e
parent  620bd22da9f75b782db693879b8b654bb4587ab2
...
1
2
 
 
 
 
 
 
3
4
5
6
 
 
 
 
 
 
7
8
9
10
 
 
 
 
 
 
11
12
13
14
 
15
16
17
18
19
 
 
20
21
22
 
 
 
 
 
 
 
 
 
 
 
23
24
25
26
 
27
28
29
30
 
31
32
33
34
 
35
36
37
38
 
 
 
 
 
 
39
40
41
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
0
@@ -1,41 +1,81 @@
0
 class Symbol
0
   
0
+  # See Mack::ViewHelpers::FormHelpers check_box for more information
0
+  # 
0
+  # Examples:
0
+  #   @user = User.new(:accepted_tos => true)
0
+  #   <%= :user.check_box :accepted_tos %> # => <input checked="checked" id="user_accepted_tos" name="user[accepted_tos]" type="checkbox" />
0
+  #   <%= :i_dont_exist.checkbox %> # => <input id="i_dont_exist" name="i_dont_exist" type="checkbox" />
0
   def check_box(*args)
0
     Thread.current[:view_template].check_box(self, *args)
0
   end
0
   
0
+  # See Mack::ViewHelpers::FormHelpers file_field for more information
0
+  # 
0
+  # Examples:
0
+  #   @user = User.new(:bio_file => "~/bio.doc")
0
+  #   <%= :user.file_field :bio_file %> # => <input id="user_bio_field" name="user[bio_field]" type="file" value="~/bio.doc" />
0
+  #   <%= :i_dont_exist.file_field %> # => <input id="i_dont_exist" name="i_dont_exist" type="file" value="" />
0
   def file_field(*args)
0
     Thread.current[:view_template].file_field(self, *args)
0
   end
0
   
0
+  # See Mack::ViewHelpers::FormHelpers hidden_field for more information
0
+  # 
0
+  # Examples:
0
+  #   @user = User.new(:email => "mark@mackframework.com")
0
+  #   <%= :user.hidden_field :email %> # => <input id="user_email" name="user[email]" type="hidden" value="mark@mackframework.com" />
0
+  #   <%= :i_dont_exist.hidden_field %> # => <input id="i_dont_exist" name="i_dont_exist" type="hidden" />
0
   def hidden_field(*args)
0
     Thread.current[:view_template].hidden_field(self, *args)
0
   end
0
   
0
+  # See Mack::ViewHelpers::FormHelpers image_submit for more information
0
   def image_submit(*args)
0
     Thread.current[:view_template].image_submit(self, *args)
0
   end
0
   
0
-  def label(*args)
0
+  # See Mack::ViewHelpers::FormHelpers label_tag for more information
0
+  def label_tag(*args)
0
     Thread.current[:view_template].label(self, *args)
0
   end
0
   
0
+  # See Mack::ViewHelpers::FormHelpers password_field for more information
0
+  # 
0
+  # Examples:
0
+  #   @user = User.new(:email => "mark@mackframework.com")
0
+  #   <%= :user.password_field :email %> # => <input id="user_email" name="user[email]" type="password" value="mark@mackframework.com" />
0
+  #   <%= :i_dont_exist.password_field %> # => <input id="i_dont_exist" name="i_dont_exist" type="password" />
0
+  def password_field(*args)
0
+    Thread.current[:view_template].password_field(self, *args)
0
+  end
0
+  
0
+  # See Mack::ViewHelpers::FormHelpers radio_button for more information
0
   def radio_button(*args)
0
     Thread.current[:view_template].radio_button(self, *args)
0
   end
0
   
0
+  # See Mack::ViewHelpers::FormHelpers select for more information
0
   def select(*args)
0
     Thread.current[:view_template].select(self, *args)
0
   end
0
   
0
+  # See Mack::ViewHelpers::FormHelpers submit for more information
0
   def submit(*args)
0
     Thread.current[:view_template].submit(self, *args)
0
   end
0
   
0
+  # See Mack::ViewHelpers::FormHelpers text_area for more information
0
   def text_area(*args)
0
     Thread.current[:view_template].text_area(self, *args)
0
   end
0
   
0
+  # See Mack::ViewHelpers::FormHelpers text_field for more information
0
+  # 
0
+  # Examples:
0
+  #   @user = User.new(:email => "mark@mackframework.com")
0
+  #   <%= :user.text_field :email %> # => <input id="user_email" name="user[email]" type="text" value="mark@mackframework.com" />
0
+  #   <%= :i_dont_exist.text_field %> # => <input id="i_dont_exist" name="i_dont_exist" type="text" />
0
   def text_field(*args)
0
     Thread.current[:view_template].text_field(self, *args)
0
   end
...
54
55
56
57
 
58
59
60
...
101
102
103
104
 
 
105
106
107
...
54
55
56
 
57
58
59
60
...
101
102
103
 
104
105
106
107
108
0
@@ -54,7 +54,7 @@ module Mack
0
         non_content_tag(:input, {:type => :image, :src => "/images/#{src}"}.merge(options))
0
       end
0
 
0
-      def label(name, *args)
0
+      def label_tag(name, *args)
0
         fe = FormElement.new(*args)
0
         unless fe.options[:for]
0
           fe.options[:for] = (fe.calling_method == :to_s ? name.to_s : "#{name}_#{fe.calling_method}")
0
@@ -101,7 +101,8 @@ module Mack
0
           sel_value = var.send(fe.calling_method) if var
0
           sel_value = fe.options[:selected] if fe.options[:selected]
0
           sopts.each do |kv|
0
-            content << %{<option value="#{kv[1]}" #{kv[1].to_s == sel_value.to_s ? "selected" : ""}>#{kv[0]}</option>}
0
+            selected = kv[1].to_s == sel_value.to_s ? "selected" : ""
0
+            content << %{<option value="#{kv[1]}" #{selected}>#{kv[0]}</option>}
0
           end
0
           fe.options.delete(:selected)
0
           fe.options.delete(:options)
...
120
121
122
123
 
124
125
126
 
127
128
129
130
 
131
132
133
134
 
135
136
137
138
 
139
140
141
142
 
143
144
145
146
 
147
148
149
...
120
121
122
 
123
124
125
 
126
127
128
129
 
130
131
132
133
 
134
135
136
137
 
138
139
140
141
 
142
143
144
145
 
146
147
148
149
0
@@ -120,30 +120,30 @@ describe Mack::ViewHelpers::FormHelpers do
0
     
0
   end
0
   
0
-  describe "label" do
0
+  describe "label_tag" do
0
     
0
     it "should create a nested label for a model" do
0
-      label(:cop, :full_name).should == %{<label for="cop_full_name">Full name</label>}
0
+      label_tag(:cop, :full_name).should == %{<label for="cop_full_name">Full name</label>}
0
     end
0
     
0
     it "should create a non-nested label for a simple object" do
0
-      label(:simple).should == %{<label for="simple">Simple</label>}
0
+      label_tag(:simple).should == %{<label for="simple">Simple</label>}
0
     end
0
     
0
     it "should create a non-nested label for just a symbol" do
0
-      label(:unknown).should == %{<label for="unknown">Unknown</label>}
0
+      label_tag(:unknown).should == %{<label for="unknown">Unknown</label>}
0
     end
0
     
0
     it "should create a non-nested label for just a symbol" do
0
-      label(:unknown).should == %{<label for="unknown">Unknown</label>}
0
+      label_tag(:unknown).should == %{<label for="unknown">Unknown</label>}
0
     end
0
     
0
     it "should create a non-nested label and use :value for it's content" do
0
-      label(:unknown, :value => "My Label").should == %{<label for="unknown">My Label</label>}
0
+      label_tag(:unknown, :value => "My Label").should == %{<label for="unknown">My Label</label>}
0
     end
0
     
0
     it "should create a non-nested label and use :for for it's for" do
0
-      label(:unknown, :for => "my_label").should == %{<label for="my_label">Unknown</label>}
0
+      label_tag(:unknown, :for => "my_label").should == %{<label for="my_label">Unknown</label>}
0
     end
0
     
0
   end

Comments