简体   繁体   English

如何使用twitter-bootstrap-rails使simple_form工作; 一般在bootstrap中形成

[英]how to make simple_form work with twitter-bootstrap-rails; form in general in bootstrap

1) How to build forms using simple form and twitter-bootstrap-rails so that they show cool bootstrap style validation errors? 1)如何使用简单的表单和twitter-bootstrap-rails构建表单,以便它们显示很酷的引导程序样式验证错误?

2) How to build forms in twitter-bootstrap-rails so that they show cool bootstrap style validation errors? 2)如何在twitter-bootstrap-rails中构建表单,以便它们显示很酷的引导程序样式验证错误?

3) I tried building form with simple_form. 3)我尝试使用simple_form构建表单。 But validation is not showing any error messages. 但验证未显示任何错误消息。 I am trying to add validation on User Model and Form generated by Devise 我正在尝试添加由Devise生成的用户模型和表单的验证

Techs: Rails 3.2.7.rc1, 1.9.2, twitter-ootstrap-rails 2.1.1, simple-form 2.0.2 Techs:Rails 3.2.7.rc1,1.9.2,twitter-ootstrap-rails 2.1.1,simple-form 2.0.2

code: 码:

 <%= 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 %>

I am not sure though if this not working or jquery is not working. 我不确定,如果这不起作用或jquery不起作用。

try this: 试试这个:

<%= f.input :email do %>
   <%= f.input_field :email %>
<% end %>

Here you can find notes about integration of the two, example app, the live app: 在这里,您可以找到关于两个示例应用程序,实时应用程序集成的说明:

https://github.com/plataformatec/simple_form/#twitter-bootstrap https://github.com/plataformatec/simple_form/#twitter-bootstrap

Try this :: 试试这个 ::

simple_form + bootstrap simple_form + bootstrap

https://github.com/plataformatec/simple_form https://github.com/plataformatec/simple_form

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM