views:

79

answers:

1

I have a form, and for layout (and future use), i would like to know how to change the default f.submit that generates a:

To a html tag that shouldn't give any errors.

What i have now is an extention on the formbuilder

In my view:

   <%= form_for resource, :as => resource_name, :url => session_path(resource_name),  :class => "form with-margin", :builder => AppFormBuilder do |f| %>
   ...
   <%= f.submit %>
   <% end %>

In my lib/appformbuilder:

class AppFormBuilder < ActionView::Helpers::FormBuilder
  def submit(text, options = {})
    options[:type] = "submit"
    @template.content_tag(:button, text, options)
  end
end

But this gives me an error:

NameError in Devise/sessions#new

Showing d:/Projects/Websites/Ruby On Rails/fact-it/app/views/devise/sessions/new.html.erb where line #11 raised:
uninitialized constant ActionView::CompiledTemplates::AppFormBuilder


8:         
9:       <p class="message error no-margin alert"><%= alert %></p>
10:       <p class="notice"><%= notice %></p>
11:       <%= form_for resource, :as => resource_name, :url => session_path(resource_name), :class => "form with-margin", :builder => AppFormBuilder do |f| %>
12:         <p><%= f.label :email %><br />
13:         <%= f.text_field :email %></p>
14: 
+2  A: 

You need put this variable in lib/app_form_builder.rb if you want use the rails autoloading.

Warning, in Rails 3 this default autoloading doesn't exist anymore. You need add this autoload directory in your application.rb

shingara
superbe! Added: config.autoload_paths << File.join(config.root, "lib") to application.rb, thanks a lot!
NicoJuicy