<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,69 +1,43 @@
 class Symbol
   
   def check_box(*args)
-    puts caller.inspect
-    fe = FormElement.new(*args)
+    Thread.current[:view_template].check_box(self, *args)
   end
   
   def file_field(*args)
-    
+    Thread.current[:view_template].file_field(self, *args)
   end
   
   def hidden_field(*args)
-    
+    Thread.current[:view_template].hidden_field(self, *args)
   end
   
   def image_submit(*args)
-    
+    Thread.current[:view_template].image_submit(self, *args)
   end
   
   def label(*args)
-    
+    Thread.current[:view_template].label(self, *args)
   end
   
   def radio_button(*args)
-    
+    Thread.current[:view_template].radio_button(self, *args)
   end
   
   def select(*args)
-    
+    Thread.current[:view_template].select(self, *args)
   end
   
   def submit(*args)
-    
+    Thread.current[:view_template].submit(self, *args)
   end
   
   def text_area(*args)
-    
+    Thread.current[:view_template].text_area(self, *args)
   end
   
   def text_field(*args)
-    
-  end
-  
-  private
-  class FormElement
-    attr_accessor :calling_method
-    attr_accessor :options
-    
-    def initialize(*args)
-      args = args.parse_splat_args
-      case args
-      when Symbol, String
-        self.calling_method = args
-      when Hash
-        self.options = args
-      when Array
-        self.calling_method = args[0]
-        self.options = args[1]
-      when nil
-        self.calling_method = :to_s
-        self.options = {}
-      else
-        raise ArgumentError.new(&quot;You must provide either a Symbol, a String, a Hash, or a combination thereof.&quot;)
-      end
-    end
-    
+    Thread.current[:view_template].text_field(self, *args)
   end
   
 end
\ No newline at end of file</diff>
      <filename>lib/mack/core_extensions/symbol.rb</filename>
    </modified>
    <modified>
      <diff>@@ -25,7 +25,7 @@ Mack::ControllerHelpers.constants.each do |cont|
 end
 
 # Find view level Helpers and include them into the Mack::Rendering::ViewTemplate
-Mack::ViewHelpers.constants.each do |cont|
-  h = &quot;Mack::ViewHelpers::#{cont}&quot;.constantize
-  h.include_safely_into(Mack::Rendering::ViewTemplate)
-end
\ No newline at end of file
+# Mack::ViewHelpers.constants.each do |cont|
+#   h = &quot;Mack::ViewHelpers::#{cont}&quot;.constantize
+#   h.include_safely_into(Mack::Rendering::ViewTemplate)
+# end
\ No newline at end of file</diff>
      <filename>lib/mack/initialization/helpers.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,6 +3,7 @@ module Mack
     # This class is used to do all the view level bindings.
     # It allows for seperation between the Mack::Controller and the view levels.
     class ViewTemplate
+      include Mack::ViewHelpers
       
       # Allows access to any options passed into the template.
       attr_accessor :options
@@ -14,6 +15,7 @@ module Mack
         self.render_value = render_value
         self.options = options
         @_yield_to_cache = {}
+        Thread.current[:view_template] = self
       end
       
       # Allows access to the current Mack::Controller object.</diff>
      <filename>lib/mack/rendering/view_template.rb</filename>
    </modified>
    <modified>
      <diff>@@ -23,11 +23,136 @@ module Mack
         # content_tag(:form, options, &amp;block)
       end
       
+      def submit_tag(value = &quot;Submit&quot;, options = {}, *original_args)
+        Mack.logger.warn(&quot;DEPRECATED: 'submit_tag'. Please use 'submit' instead&quot;)
+        submit(value, options, *original_args)
+      end
+      
       # Builds an HTML submit tag
-      def submit_tag(value = &quot;Submit&quot;, options = {})
+      def submit(value = &quot;Submit&quot;, options = {}, *original_args)
         non_content_tag(:input, {:type =&gt; :submit, :value =&gt; value}.merge(options))
       end
       
+      def check_box(name, *args)
+        build_form_element(name, {:type =&gt; :checkbox}, *args) do |var, fe, options|
+          if options[:value]
+            options.merge!(:checked =&gt; &quot;checked&quot;)
+          end
+          options.delete(:value)
+        end
+      end
+
+      def file_field(name, *args)
+        build_form_element(name, {:type =&gt; :file}, *args)
+      end
+
+      def hidden_field(name, *args)
+        build_form_element(name, {:type =&gt; :hidden}, *args)
+      end
+
+      def image_submit(src, options = {})
+        non_content_tag(:input, {:type =&gt; :image, :src =&gt; &quot;/images/#{src}&quot;}.merge(options))
+      end
+
+      def label(name, *args)
+        fe = FormElement.new(*args)
+        unless fe.options[:for]
+          fe.options[:for] = (fe.calling_method == :to_s ? name.to_s : &quot;#{name}_#{fe.calling_method}&quot;)
+        end
+        unless fe.options[:value]
+          fe.options[:value] = (fe.calling_method == :to_s ? name.to_s.humanize : fe.calling_method.to_s.humanize)
+        end
+        content = fe.options[:value]
+        fe.options.delete(:value)
+        content_tag(:label, fe.options, content)
+      end
+
+      def radio_button(name, *args)
+        build_form_element(name, {:type =&gt; :radio}, *args) do |var, fe, options|
+          if options[:value]
+            options.merge!(:checked =&gt; &quot;checked&quot;)
+          end
+          options.delete(:value)
+        end
+      end
+
+      def select(name, *args)
+
+      end
+
+      def text_area(name, *args)
+        var = instance_variable_get(&quot;@#{name}&quot;)
+        fe = FormElement.new(*args)
+        options = {:name =&gt; name, :id =&gt; name}
+        if var.nil?
+          return content_tag(:textarea, options.merge(fe.options))
+        else
+          unless fe.calling_method == :to_s
+            options.merge!(:name =&gt; &quot;#{name}[#{fe.calling_method}]&quot;, :id =&gt; &quot;#{name}_#{fe.calling_method}&quot;)
+          end
+          options[:value] = var.send(fe.calling_method)
+          
+          yield var, fe, options if block_given?
+          
+          content = options[:value]
+          options.delete(:value)
+          
+          return content_tag(:textarea, options.merge(fe.options), content)
+        end
+      end
+
+      def text_field(name, *args)
+        build_form_element(name, {:type =&gt; :text}, *args)
+      end
+      
+      def password_field(name, *args)
+        build_form_element(name, {:type =&gt; :password}, *args)
+      end
+      
+      private
+      def build_form_element(name, options, *original_args)
+        var = instance_variable_get(&quot;@#{name}&quot;)
+        options = {:name =&gt; name, :id =&gt; name}.merge(options)
+        if var.nil?
+          return non_content_tag(:input, options)
+        else
+          fe = FormElement.new(*original_args)
+          unless fe.calling_method == :to_s
+            options.merge!(:name =&gt; &quot;#{name}[#{fe.calling_method}]&quot;, :id =&gt; &quot;#{name}_#{fe.calling_method}&quot;)
+          end
+          options[:value] = var.send(fe.calling_method)
+          
+          yield var, fe, options if block_given?
+          
+          return non_content_tag(:input, options.merge(fe.options))
+        end
+      end
+      
+      class FormElement
+
+        attr_accessor :calling_method
+        attr_accessor :options
+
+        def initialize(*args)
+          args = args.parse_splat_args
+          self.calling_method = :to_s
+          self.options = {}
+          case args
+          when Symbol, String
+            self.calling_method = args
+          when Hash
+            self.options = args
+          when Array
+            self.calling_method = args[0]
+            self.options = args[1]
+          when nil
+          else
+            raise ArgumentError.new(&quot;You must provide either a Symbol, a String, a Hash, or a combination thereof.&quot;)
+          end
+        end
+
+      end
+      
       
     end # FormHelpers
   end # ViewHelpers</diff>
      <filename>lib/mack/view_helpers/form_helpers.rb</filename>
    </modified>
    <modified>
      <diff>@@ -39,6 +39,9 @@ module Mack
       
       private
       def build_options(options)
+        if options[:disabled]
+          options[:disabled] = :disabled
+        end
         opts = &quot;&quot;
         unless options.empty?
           opts = &quot; &quot; &lt;&lt; options.join(&quot;%s=\&quot;%s\&quot;&quot;, &quot; &quot;)</diff>
      <filename>lib/mack/view_helpers/html_helpers.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,6 +4,222 @@ require Pathname(__FILE__).dirname.expand_path.parent.parent + 'spec_helper'
 describe Mack::ViewHelpers::FormHelpers do
   include Mack::ViewHelpers
   
+  class Cop
+    attr_accessor :full_name
+    attr_accessor :level
+    attr_accessor :tos
+    attr_accessor :bio_file
+  end
+
+  before(:each) do
+    @cop = Cop.new
+    @cop.full_name = &quot;ness&quot;
+    @cop.level = 1
+    @cop.bio_file = &quot;~/bio.doc&quot;
+    @simple = &quot;hi&quot;
+    @default_file = &quot;~/resume.doc&quot;
+  end
+  
+  describe &quot;check_box&quot; do
+    
+    it &quot;should create a nested checkbox for a model&quot; do
+      check_box(:cop, :tos).should == %{&lt;input id=&quot;cop_tos&quot; name=&quot;cop[tos]&quot; type=&quot;checkbox&quot; /&gt;}
+    end
+    
+    it &quot;should create a non-nested checkbox for a simple object&quot; do
+      check_box(:simple).should == %{&lt;input checked=&quot;checked&quot; id=&quot;simple&quot; name=&quot;simple&quot; type=&quot;checkbox&quot; /&gt;}
+    end
+    
+    it &quot;should create a non-nested checkbox for just a symbol&quot; do
+      check_box(:unknown).should == %{&lt;input id=&quot;unknown&quot; name=&quot;unknown&quot; type=&quot;checkbox&quot; /&gt;}
+    end
+    
+    it &quot;should be checked if the value is true&quot; do
+      @cop.tos = true
+      check_box(:cop, :tos).should == %{&lt;input checked=&quot;checked&quot; id=&quot;cop_tos&quot; name=&quot;cop[tos]&quot; type=&quot;checkbox&quot; /&gt;}
+    end
+    
+    it &quot;should be unchecked if the value is false&quot; do
+      @cop.tos = false
+      check_box(:cop, :tos).should == %{&lt;input id=&quot;cop_tos&quot; name=&quot;cop[tos]&quot; type=&quot;checkbox&quot; /&gt;}
+    end
+    
+  end
+  
+  describe &quot;file_field&quot; do
+    
+    it &quot;should create a nested file_field for a model&quot; do
+      file_field(:cop, :bio_file).should == %{&lt;input id=&quot;cop_bio_file&quot; name=&quot;cop[bio_file]&quot; type=&quot;file&quot; value=&quot;~/bio.doc&quot; /&gt;}
+    end
+    
+    it &quot;should create a non-nested file_field for a simple object&quot; do
+      file_field(:default_file).should == %{&lt;input id=&quot;default_file&quot; name=&quot;default_file&quot; type=&quot;file&quot; value=&quot;~/resume.doc&quot; /&gt;}
+    end
+    
+    it &quot;should create a non-nested file_field for just a symbol&quot; do
+      file_field(:unknown).should == %{&lt;input id=&quot;unknown&quot; name=&quot;unknown&quot; type=&quot;file&quot; /&gt;}
+    end
+
+    it &quot;should create a nested file_field for a model with an empty value if value is false&quot; do
+      @cop.bio_file = nil
+      file_field(:cop, :bio_file).should == %{&lt;input id=&quot;cop_bio_file&quot; name=&quot;cop[bio_file]&quot; type=&quot;file&quot; value=&quot;&quot; /&gt;}
+    end
+    
+  end
+  
+  describe &quot;hidden_field&quot; do
+    
+    it &quot;should create a nested hidden_field for a model&quot; do
+      hidden_field(:cop, :full_name).should == %{&lt;input id=&quot;cop_full_name&quot; name=&quot;cop[full_name]&quot; type=&quot;hidden&quot; value=&quot;ness&quot; /&gt;}
+    end
+    
+    it &quot;should create a non-nested hidden_field for a simple object&quot; do
+      hidden_field(:simple).should == %{&lt;input id=&quot;simple&quot; name=&quot;simple&quot; type=&quot;hidden&quot; value=&quot;hi&quot; /&gt;}
+    end
+    
+    it &quot;should create a non-nested hidden_field for just a symbol&quot; do
+      hidden_field(:unknown).should == %{&lt;input id=&quot;unknown&quot; name=&quot;unknown&quot; type=&quot;hidden&quot; /&gt;}
+    end
+
+    it &quot;should create a nested hidden_field for a model with an empty value if value is false&quot; do
+      @cop.full_name = nil
+      hidden_field(:cop, :full_name).should == %{&lt;input id=&quot;cop_full_name&quot; name=&quot;cop[full_name]&quot; type=&quot;hidden&quot; value=&quot;&quot; /&gt;}
+    end
+    
+  end
+  
+  describe &quot;password_field&quot; do
+    
+    it &quot;should create a nested password_field for a model&quot; do
+      password_field(:cop, :full_name).should == %{&lt;input id=&quot;cop_full_name&quot; name=&quot;cop[full_name]&quot; type=&quot;password&quot; value=&quot;ness&quot; /&gt;}
+    end
+    
+    it &quot;should create a non-nested password_field for a simple object&quot; do
+      password_field(:simple).should == %{&lt;input id=&quot;simple&quot; name=&quot;simple&quot; type=&quot;password&quot; value=&quot;hi&quot; /&gt;}
+    end
+    
+    it &quot;should create a non-nested password_field for just a symbol&quot; do
+      password_field(:unknown).should == %{&lt;input id=&quot;unknown&quot; name=&quot;unknown&quot; type=&quot;password&quot; /&gt;}
+    end
+
+    it &quot;should create a nested password_field for a model with an empty value if value is false&quot; do
+      @cop.full_name = nil
+      password_field(:cop, :full_name).should == %{&lt;input id=&quot;cop_full_name&quot; name=&quot;cop[full_name]&quot; type=&quot;password&quot; value=&quot;&quot; /&gt;}
+    end
+    
+  end
+  
+  describe &quot;image_submit&quot; do
+    
+    it &quot;should create an image submit tag&quot; do
+      image_submit(&quot;login.png&quot;).should == %{&lt;input src=&quot;/images/login.png&quot; type=&quot;image&quot; /&gt;}
+      image_submit(&quot;purchase.png&quot;, :disabled =&gt; true).should == %{&lt;input disabled=&quot;disabled&quot; src=&quot;/images/purchase.png&quot; type=&quot;image&quot; /&gt;}
+      image_submit(&quot;search.png&quot;, :class =&gt; 'search-button').should == %{&lt;input class=&quot;search-button&quot; src=&quot;/images/search.png&quot; type=&quot;image&quot; /&gt;}
+    end
+    
+  end
+  
+  describe &quot;label&quot; do
+    
+    it &quot;should create a nested label for a model&quot; do
+      label(:cop, :full_name).should == %{&lt;label for=&quot;cop_full_name&quot;&gt;Full name&lt;/label&gt;}
+    end
+    
+    it &quot;should create a non-nested label for a simple object&quot; do
+      label(:simple).should == %{&lt;label for=&quot;simple&quot;&gt;Simple&lt;/label&gt;}
+    end
+    
+    it &quot;should create a non-nested label for just a symbol&quot; do
+      label(:unknown).should == %{&lt;label for=&quot;unknown&quot;&gt;Unknown&lt;/label&gt;}
+    end
+    
+    it &quot;should create a non-nested label for just a symbol&quot; do
+      label(:unknown).should == %{&lt;label for=&quot;unknown&quot;&gt;Unknown&lt;/label&gt;}
+    end
+    
+    it &quot;should create a non-nested label and use :value for it's content&quot; do
+      label(:unknown, :value =&gt; &quot;My Label&quot;).should == %{&lt;label for=&quot;unknown&quot;&gt;My Label&lt;/label&gt;}
+    end
+    
+    it &quot;should create a non-nested label and use :for for it's for&quot; do
+      label(:unknown, :for =&gt; &quot;my_label&quot;).should == %{&lt;label for=&quot;my_label&quot;&gt;Unknown&lt;/label&gt;}
+    end
+    
+  end
+  
+  describe &quot;radio_button&quot; do
+    
+    it &quot;should create a nested radio_button for a model&quot; do
+      radio_button(:cop, :tos).should == %{&lt;input id=&quot;cop_tos&quot; name=&quot;cop[tos]&quot; type=&quot;radio&quot; /&gt;}
+    end
+    
+    it &quot;should create a non-nested radio_button for a simple object&quot; do
+      radio_button(:simple).should == %{&lt;input checked=&quot;checked&quot; id=&quot;simple&quot; name=&quot;simple&quot; type=&quot;radio&quot; /&gt;}
+    end
+    
+    it &quot;should create a non-nested radio_button for just a symbol&quot; do
+      radio_button(:unknown).should == %{&lt;input id=&quot;unknown&quot; name=&quot;unknown&quot; type=&quot;radio&quot; /&gt;}
+    end
+    
+    it &quot;should be checked if the value is true&quot; do
+      @cop.tos = true
+      radio_button(:cop, :tos).should == %{&lt;input checked=&quot;checked&quot; id=&quot;cop_tos&quot; name=&quot;cop[tos]&quot; type=&quot;radio&quot; /&gt;}
+    end
+    
+    it &quot;should be unchecked if the value is false&quot; do
+      @cop.tos = false
+      radio_button(:cop, :tos).should == %{&lt;input id=&quot;cop_tos&quot; name=&quot;cop[tos]&quot; type=&quot;radio&quot; /&gt;}
+    end
+    
+  end
+  
+  describe &quot;select&quot; do
+    
+  end
+  
+  describe &quot;text_area&quot; do
+    
+    it &quot;should create a nested text_area for a model&quot; do
+      text_area(:cop, :full_name).should == %{&lt;textarea id=&quot;cop_full_name&quot; name=&quot;cop[full_name]&quot;&gt;ness&lt;/textarea&gt;}
+    end
+    
+    it &quot;should create a non-nested text_area for a simple object&quot; do
+      text_area(:simple).should == %{&lt;textarea id=&quot;simple&quot; name=&quot;simple&quot;&gt;hi&lt;/textarea&gt;}
+    end
+    
+    it &quot;should create a non-nested text_area for just a symbol&quot; do
+      text_area(:unknown).should == %{&lt;textarea id=&quot;unknown&quot; name=&quot;unknown&quot;&gt;&lt;/textarea&gt;}
+    end
+
+    it &quot;should create a nested text_area for a model with an empty value if value is false&quot; do
+      @cop.full_name = nil
+      text_area(:cop, :full_name).should == %{&lt;textarea id=&quot;cop_full_name&quot; name=&quot;cop[full_name]&quot;&gt;&lt;/textarea&gt;}
+    end
+    
+  end
+  
+  describe &quot;text_field&quot; do
+    
+    it &quot;should create a nested text_field for a model&quot; do
+      text_field(:cop, :full_name).should == %{&lt;input id=&quot;cop_full_name&quot; name=&quot;cop[full_name]&quot; type=&quot;text&quot; value=&quot;ness&quot; /&gt;}
+    end
+    
+    it &quot;should create a non-nested text_field for a simple object&quot; do
+      text_field(:simple).should == %{&lt;input id=&quot;simple&quot; name=&quot;simple&quot; type=&quot;text&quot; value=&quot;hi&quot; /&gt;}
+    end
+    
+    it &quot;should create a non-nested text_field for just a symbol&quot; do
+      text_field(:unknown).should == %{&lt;input id=&quot;unknown&quot; name=&quot;unknown&quot; type=&quot;text&quot; /&gt;}
+    end
+
+    it &quot;should create a nested text_field for a model with an empty value if value is false&quot; do
+      @cop.full_name = nil
+      text_field(:cop, :full_name).should == %{&lt;input id=&quot;cop_full_name&quot; name=&quot;cop[full_name]&quot; type=&quot;text&quot; value=&quot;&quot; /&gt;}
+    end
+    
+  end
+  
+  
   describe &quot;form&quot; do
     include CommonHelpers
     
@@ -43,18 +259,18 @@ Hello
     
   end
   
-  describe &quot;submit_tag&quot; do
+  describe &quot;submit&quot; do
     
     it &quot;should build a simple submit tag&quot; do
-      submit_tag.should == %{&lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;}
+      submit.should == %{&lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;}
     end
     
     it &quot;should allow you to change the value&quot; do
-      submit_tag(&quot;Login&quot;).should == %{&lt;input type=&quot;submit&quot; value=&quot;Login&quot; /&gt;}
+      submit(&quot;Login&quot;).should == %{&lt;input type=&quot;submit&quot; value=&quot;Login&quot; /&gt;}
     end
     
     it &quot;should take options&quot; do
-      submit_tag(&quot;Login&quot;, {:class =&gt; :foo}).should == %{&lt;input class=&quot;foo&quot; type=&quot;submit&quot; value=&quot;Login&quot; /&gt;}
+      submit(&quot;Login&quot;, {:class =&gt; :foo}).should == %{&lt;input class=&quot;foo&quot; type=&quot;submit&quot; value=&quot;Login&quot; /&gt;}
     end
     
   end</diff>
      <filename>test/unit/view_helpers/form_helpers_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>test/unit/core_extensions/symbol_spec.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>484cb93a90cc2900b73737e03f0d85e362610f86</id>
    </parent>
  </parents>
  <author>
    <name>Mark Bates</name>
    <email>mark@markbates.com</email>
  </author>
  <url>http://github.com/markbates/mack/commit/25aed1978f46fb7a93ba6695563aa9ae4103c20d</url>
  <id>25aed1978f46fb7a93ba6695563aa9ae4103c20d</id>
  <committed-date>2008-08-14T11:24:01-07:00</committed-date>
  <authored-date>2008-08-14T11:24:01-07:00</authored-date>
  <message>More work on adding html form helpers. [#19]</message>
  <tree>9a1b167645538c9ddab92de092649c35a0518e77</tree>
  <committer>
    <name>Mark Bates</name>
    <email>mark@markbates.com</email>
  </committer>
</commit>
