simple-form

simple_form render radio button group with <image>( X ) Label with twitter bootstrap?

落花浮王杯 提交于 2019-11-30 04:35:01
问题 Im trying for some time to use simple_form to create the below example but + the label and fixing some styling. Anyone knows how to fix: remove the 2 's no idea where they come from (seems strange i18n bug on production it throws a whole bunch of I18n in ) Have the text Male or Female after the radio button Is the result from below code: .clear = f.label "Gender" = f.collection_radio_buttons(:gender, [['Male', 'icon_male'], ['Female', 'icon_female']], :first, :last, :item_wrapper_class =>

Is there a way to submit ajax/json requests with simple_form for Rails

▼魔方 西西 提交于 2019-11-30 04:20:37
问题 With the standard Rails form_for, I was able to pass ajax requests though select and collection_select helpers as such: <%= address.collection_select :country, @countries, :id, :name, {:include_blank => false}, "data-remote" => true, "data-url" => "/ajax/states", "data-type" => :json %> I can't seem to figure out how to do this with simple_form 回答1: Figured it out. You just need to add the this: :input_html => {"data-remote" => true, "data-url" => "/yoururl", "data-type" => :json} 回答2: It is

Rails 4 simple_form collection_select

∥☆過路亽.° 提交于 2019-11-30 02:59:00
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. 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 %> <%= f.button :submit %> <%end%> Hope this help Here is the final: <%= f.input :location_id, collection:

Styling file upload button for simple_form_for with Bootstrap in Rails 3

落爺英雄遲暮 提交于 2019-11-29 23:59:53
Using simple_form_for, Bootstrap and Rails 3. In a form: <%= f.input :upload, label: 'PDF file:' , input_html: {accept: ('application/pdf') } %> I don't know how I'd style this so that the "choose file" button can have a different class ('btn btn-primary'). Additionally, when using with Bootstrap at least, its severely misaligned by default. See attached image. Finally, how do I redefine the text from "No file chosen" to "Chose file" when there isn't one added yet, and show the file name when there is one. This is how I do it: In the view add your form file field and hide it Add a styled

How to apply tags with acts_as_taggable_on using check boxes?

六眼飞鱼酱① 提交于 2019-11-29 23:23:28
I would like to assign two different "types" of tags (sector categories and free tagging) to a Company model using acts_as_taggable_on . NB: I'm new to RoR! This is easy to do if just using standard text input fields, but I would like to use check-boxes on one type (a fixed sector category tag that is predefined), and then allow the user to add comma separated tags in an input field. I have played around with this problem in various ways,... one inspired by this question ...but I cannot get it to work Here is what I have so far: # models/company.rb class Company ... acts_as_taggable_on :tags,

Grouped Collection Select Alphabetical Order Rails

六月ゝ 毕业季﹏ 提交于 2019-11-29 22:27:13
问题 I finally figured out how to implement Dynamic Select menus using this tutorial. Everything works, But how does one organize the Cities in the Dropdown by Name.... Below is all of the code I've written. (Please let me know if you need any further information) New to rails please help :) VIEWS <%= simple_form_for ([@book, @rating]) do |f| %> <div class="field"> <%= f.collection_select :state_id, State.order(:name), :id, :name, {:include_blank=> "Select a State"}, {:class=>'dropdown'} %> </div>

Rails: Using simple_form and integrating Twitter Bootstrap

南笙酒味 提交于 2019-11-29 20:43:00
I'm trying to build a rails app and simple_form looks to be a really useful gem. Problem is that I am using twitter bootstrap css to do the styling and the simple_form doesn't allow you to specify the layout of the html. Can anyone tell me how I can conform the simple_form html into the format bootstrap css wants? Note: This answer only applies to SimpleForm < 2.0 Start with this in config/initializers/simple_form.rb : SimpleForm.form_class = nil SimpleForm.wrapper_class = 'clearfix' SimpleForm.wrapper_error_class = 'error' SimpleForm.error_class = 'help-inline' Then there's space missing

Adding a default value to text-input in simple-form

好久不见. 提交于 2019-11-29 16:01:47
问题 I want to add a default value to a text-input field using simple-form. With :placeholder it is not used as default.... <%= f.input :user, :placeholder => 'user@domain.com' %> 回答1: <%= f.input :user, :input_html => { :value => 'user@domain.com' } %> 回答2: You can simply do: <% f.text_field, value: 'user@admin.com' %> text_field is good if you are working with form search gem like Ransack. 回答3: On rails 5.1 placeholder: 'aaaaaaaaaaa' works. E.g. <%= f.input :user, :placeholder => 'user@domain

Creating multiple records for a model in a single view in Rails

╄→гoц情女王★ 提交于 2019-11-29 15:47:25
问题 I have a model named Book , and I want to adjust the standard Book#new to show the fields for 10 books, so that 10 can be created at once instead of just one. I looked at this question and found that I could repeat the form if I added 10.times to my form. However, I didn't do it correctly because a new record is saved, but with all fields null. What I want to do is to: Allow the user to enter up to 10 books at one-time and then save them If the user populates only three book records, create

Controller can not detect ajax requests

你离开我真会死。 提交于 2019-11-29 13:59:35
I am using simple_form gem and generating the form I am specifying the remote:true option like this: <%= simple_form_for @webinar, validate: true, remote:true do |f| %> So, the output html for the form is the following fragment: <form accept-charset="UTF-8" action="/webinars" class="simple_form new_webinar" data-remote="true" data-validate="true" enctype="multipart/form-data" id="new_webinar" method="post" novalidate="novalidate"> ... </form> As I checked, using the standard form_for helper is adding the data-remote='true' to the form when remote:true options is used. And as you can see from