simple-form

Rails 4, Bootstrap 3, simple_form - form styling not working

你。 提交于 2019-12-10 13:28:04
问题 In the past I have used rails 3.x bootstrap 2.x and simple_form to great success. However, I have tried to created a new (not upgraded) Rails 4 / Bootstrap 3 app and although the simple_form syntax is able to be used and can even use nested forms, it looks as though the styling is not working. I have used rails-bootstrap-forms on a none model based form and that styling looks fine, however, I would prefer to use simple_form for the majority of my forms. My files look like the following gem

Ruby on Rails : simple form, add Image next to each input field

拜拜、爱过 提交于 2019-12-10 13:06:25
问题 When i use rails, i create a simple form using simple form gem I create a form like this <%= simple_form_for @user do |f| %> <%= f.input :username %> <%= f.input :password %> <%= f.button :submit %> <% end %> but i would like to add an default image element just next to each fields. how can i achieve that? i try this <%= simple_form_for @user do |f| %> <%= f.input :username % > <img xxxx> <%= f.input :password %> <img xxxx> <%= f.button :submit %> <img xxxx> <% end %> but i won't work as it

Simple_form input as both text and autocomplete

天涯浪子 提交于 2019-12-10 12:06:21
问题 I am using gem 'simple_form', '2.0' and gem 'rails3-jquery-autocomplete', '1.0.10'. I am unable to make a string field accept two ':as' arguments. <%= f.input :product_description , :url => autocomplete_product_name_products_path, :as => :text, :as => :autocomplete, :placeholder=>"Type product name", :input_html => {:class =>"span2", :rows => 6}, wrapper: :inline_label, label:false %> If I remove :as => :text, the auto-complete part works but ':rows => 6' part fail. And if I keep both, I get

Prepended input label (simple_form + bootstrap-sass) off by a few pixels

我的未来我决定 提交于 2019-12-10 07:33:11
问题 I want to use the text input field seen here: http://simple-form-bootstrap.plataformatec.com.br/articles/new (It's the second text input field on that page.) I have it working in other Rails apps but for some reason in my current one there is a several-pixel gap between the prepended label and the text input. I've installed simple_form with the --bootstrap option, and have verified that the Rails/haml/bootstrap/bootstrap-sass versions are the same as the working rails app. I don't override

Rails: Twitter Bootstrap Buttons when visited get black text color

ぐ巨炮叔叔 提交于 2019-12-10 03:29:15
问题 I have a rails 3.2 app using Twitter Bootstrap via the gem ' twitter-bootstrap-rails '. Additionally the forms are created with the SimpleForm gem For a number of the pages I've used the twitter buttons on the form via <%= link_to "Back", :back, :class => 'btn btn-warning'%> <%= form.button :submit, :class => 'btn btn-primary' %> The buttons are rendered ok. The issue is that after you select one of the buttons, which visits the link, on returning to the page the text is stuck on the greyed

Simple Form: Is it possible to remove labels and replace them with placeholders using the labels i18n? [duplicate]

江枫思渺然 提交于 2019-12-10 01:09:52
问题 This question already has answers here : How to use placeholders instead of labels in simple_form? (4 answers) Closed 5 years ago . I'm trying to produce a regular simpleform form = simple_form_for [:hq, @team, @order] do |f| .tickets = f.select :tickets, :aaa => "aaa" = render "ticket" .details .left = f.input :address1 = f.input :address2 = f.input :state = f.input :country = f.input :email .right = f.input :comments But I want the inputs to not be rendered with a label, just the title

nested attributes in simple_form returns mass assignment error

主宰稳场 提交于 2019-12-09 22:36:47
问题 Models: class Topic < ActiveRecord::Base has_many :posts, :dependent => :destroy validates :name, :presence => true, :length => { :maximum => 32 } attr_accessible :name, :post_id end class Post < ActiveRecord::Base belongs_to :topic, :touch => true has_many :comments, :dependent => :destroy accepts_nested_attributes_for :topic attr_accessible :name, :title, :content, :topic, :topic_attributes end View: <%= simple_form_for :post, :url => { :controller => :posts, :action => "create" } do |f| %>

Simple_form class form-horizontal with bootstrap 3 not working in rails 4

廉价感情. 提交于 2019-12-09 12:04:39
问题 I have two rails apps, and the 'form-horizontal' is working in one, but not the other, and I have no idea why. First app is called "Horizontal" (my test app) and the other is "Inventory" Form in "horizontal" app: <%= simple_form_for(@part, html: {class: 'form-horizontal' }) do |f| %> <div class="field"> <%= f.input :name %> </div> <div class="field"> <%= f.input :number %> </div> <div class="actions"> <%= f.submit %> </div> <% end %> and looks like this in the browser: and the form for the

Rails 4 simple_form collection_select

泪湿孤枕 提交于 2019-12-08 23:09:30
问题 How do I translate the following to simple form? <%= form_for(@bill) do |f| %> <%= f.label :location_id %> <%= f.collection_select(:location_id, @locations, :id, :location_name, {:selected => @bill.location_id}) %> I can't use a simple association because @locations is the result of a where query. 回答1: Try this <%= simple_form_for @bill do |f| %> <%= f.input :location,:collection => @locations,:label_method => :location_name,:value_method => :id,:label => "Location" ,:include_blank => false %

Rails Forms : change form fields from previously selected fields

时光毁灭记忆、已成空白 提交于 2019-12-08 20:04:30
I have two simple_form fields like this: <%= f.input :ration_card ,as: :radio_buttons,collection: ["Yes","No"], input_html: {id: "rationcard"} %> <%= f.input :rationcardNum , label: "Ration Card No." ,input_html: {id: "rationcard_no"} %> I want to show the second field only if user selects "Yes" for the first field. My Jquery: $(function(){ $("#rationcard").change(function(){ if ($("#rationcard").val()=="Yes"){ $("#rationcard_no").show(); } else { $("#rationcard_no").hide(); } }) }) I can see the js file being included at head of the page. generated HTML: <div class="control-group radio