开发者

RoR 3 - overriding the FormBuilder default f.submit into a button

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 =&g开发者_如何转开发t; "form with-margin", :builder => AppFormBuilder do |f| %>
12:         <p><%= f.label :email %><br />
13:         <%= f.text_field :email %></p>
14: 


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜