2012-07-26 62 views
3

1)如何使用简单的窗体和twitter-bootstrap-rails构建窗体,以便它们显示很酷的引导程序样式验证错误?如何使simple_form与twitter-bootstrap-rails一起工作;一般在引导的形式

2)如何在twitter-bootstrap-rails中创建表单以便它们显示很酷的引导样式验证错误?

3)我试着用simple_form构建窗体。但验证不会显示任何错误消息。我想用户模型添加验证,并形成由Devise

科技股产生:Rails的3.2.7.rc1,1.9.2,Twitter的ootstrap护栏2.1.1,简单的形式2.0.2

代码:

<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => {:class => 'form-vertical' }) do |f| %> 

     <%= f.error_notification %> 
    <%= f.input :fname, :placeholder=>"First name", :input_html => { :class => "enroll_input span4"} %> 
    <%= f.input :lname, :placeholder=>"Last name", :input_html => { :class => "enroll_input span4"} %> 
    <%= f.input :email,:placeholder=>"Email",:input_html => { :class => "enroll_input span4"} %> 
    <%= f.input :password, :placeholder=>"Password",:input_html => { :class => "enroll_input span4"} %> 
    <div class="enroll_button"> <%= f.submit " Enroll ", :class=>"btn btn-primary pull-right btn-large" %></div> 
     <% end %> 

我不知道但如果这不工作或jquery不工作。

+0

请显示您尝试过的一些代码。 – 2012-07-26 07:34:13

+0

Holger只是:更新代码 – 2012-07-26 07:58:35

+0

请确保您使用'bootstrap'作为此表单的默认包装。参见'config/initializers/simple_form.rb'中的'config.default_wrapper =:bootstrap'。要使用bootstrap包装生成simple_form配置,请使用以下命令:'rails generate simple_form:install --bootstrap' – melekes 2012-07-26 15:06:19

回答

3

试试这个:

<%= f.input :email do %> 
    <%= f.input_field :email %> 
<% end %> 
相关问题