simple-form

Label tag wrapping Input tag in radio buttons (Simple_form)

时间秒杀一切 提交于 2019-12-25 02:51:59
问题 I'm using the gem simple_form with Rails to create my forms. I want to create radio_buttons that have the input tag wrapped in the label tag, for example: <label> <input id="optionsRadios2" name="optionsRadios" value="option2" type="radio"/> Option one </label> but what I get is this: <input id="optionsRadios" name="optionsRadios" value="option2" type="radio"/> <label for="optionsRadios1"> Option one</label> Is there a way to create the input tag inside label tag using wrappers? how? I could

Rails form won't select default value

陌路散爱 提交于 2019-12-25 02:37:53
问题 Rails 4.0 Ruby 2.0, SimpleForm 3.1.0.rc2 Why isn't the default value selected in the first example when It is selected in the second example? Both examples are in the same form. More to the point, I suppose, is how do I fix it? Thanks. <%= f.input(:location_id, {input_html: {value: @car.location}, collection: Location.all.order("name").collect{|c| [c.name, c.id]}, prompt: "Location?"}) %> <select id="car_location_id" class="select optional form-control form-control" value="Rcving" name="car

How do you make each option in a drop down menu a link with the association simple_form call?

假装没事ソ 提交于 2019-12-24 04:23:27
问题 I have this form using the simple_form plugin: <%= simple_form_for([@video, @video.comments.new], :remote => true) do |f| %> <%= f.association :comment_title, :collection => @video.comment_titles, :label => "Comment Title:", :include_blank => false %> <%= f.input :body, :label => false, :placeholder => "Post a comment." %> <%= f.button :submit, :value => "Post" %> <% end %> and this creates a drop down list with this line: <%= f.association :comment_title, :collection => @video.comment_titles

Rails simple_form label_html

a 夏天 提交于 2019-12-24 01:13:18
问题 I'd like to override the margin between the input & its label on one form -- can this be done via :label_html => .... ? The example on github shows a :class => 'special' being passed. Do I need to set up something in my .css file? if so, how would I do that (meaning, do I label it with a ., or a #, or nothing)? The css I've got has a "simple_form label" with some settings, I'm guessing I need to do something similar, but I'm just having difficulty putting the pieces together.. Thanks 回答1: Yes

Adding html ID to rails select options

╄→尐↘猪︶ㄣ 提交于 2019-12-24 00:52:55
问题 We're using simple_form and trying to add an id to each of a specific select_tag's options. Here is our select: <%= f.input :category, collection: %w{ Football Basketball Golf Soccer }, :include_blank => "Choose one" %> Here is what it can look like after we add the id/ids <select class="select required form-control" id="sport_category" name="sport[category]"> <option value="">Choose one</option> <option value="Football">Football</option> <option id="addBehavior" value="Basketball">Basketball

Nested attributes not showing up in simple form

拥有回忆 提交于 2019-12-23 10:09:02
问题 Given the following: Models class Location < ActiveRecord::Base has_many :games end class Game < ActiveRecord::Base validates_presence_of :sport_type has_one :location accepts_nested_attributes_for :location end Controller def new @game = Game.new end View (form) <%= simple_form_for @game do |f| %> <%= f.input :sport_type %> <%= f.input :description %> <%= f.simple_fields_for :location do |location_form| %> <%= location_form.input :city %> <% end %> <%= f.button :submit %> <% end %> Why the

How to add a switch toggle button to simple form in rails

主宰稳场 提交于 2019-12-23 09:25:10
问题 I'm using Rails 4 and Simple Form with Bootstrap. I want that my checkbox will not like that: <%= c.input :my_bool_field, label: false, class: "form-control" %> but something like that (I have the CSS for that) <label class="switch switch-primary"> <input type="checkbox" /> <span></span> </label> I know I can use simple_form wrappers, but I find them a little bit confusing.. Can someone help me up creating the checkbox with that styling? 回答1: I found this project very useful and complete. It

Can't create Custom inputs for some (Text, Booleans, …) types, with SimpleForm

百般思念 提交于 2019-12-23 05:43:11
问题 I can't figure out why this is not working as it should - or - I'm missing something important ? Here's the list of the mapped types from simple_form / lib / simple_form / form_builder.rb : map_type :text, :to => SimpleForm::Inputs::TextInput map_type :file, :to => SimpleForm::Inputs::FileInput map_type :string, :email, :search, :tel, :url, :to => SimpleForm::Inputs::StringInput map_type :password, :to => SimpleForm::Inputs::PasswordInput map_type :integer, :decimal, :float, :to => SimpleForm

how to style simple_form with material design or custom css

廉价感情. 提交于 2019-12-23 05:35:18
问题 I want style my simple_form in rails app with material framwork this is my login form code Log in <%= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> <div class="form-inputs"> <%= f.input :login %> <%= f.input :password, required: false %> <%= f.input :remember_me, as: :boolean if devise_mapping.rememberable? %> </div> <div class="form-actions"> <%= f.button :submit, "Log in" %> </div> <% end %> And this is sample input , i want sytle my form like this

Cannot find FakeInput

我是研究僧i 提交于 2019-12-23 05:27:44
问题 I am trying add a fake input to simple_form using the following suggestion (rails simple_form fields not related to the model), but it does not work for me. This is my HAML code for adding a fake input field. = f.input :agrees_to_terms, :as => :fake I put the following class in app/inputs/fake_input.rb class FakeInput < SimpleForm::Inputs::StringInput # This method only create a basic input without reading any value from object def input template.text_field_tag(attribute_name, nil, input_html