simple-form

how to specify label for select in simpleform rails

邮差的信 提交于 2019-12-03 10:10:19
<%= f.association :opportunity_status, :label => "Status", :input_html => {} %> <%= f.select :source_type, options_for_select(["lead","vteam"],["lead"]) %> On first line every thing is OK. On second line if I attach label the way I did in first line it show an error. How can I specify label for select using simpleform? This is because f.select is not a simple_form method and does not support :label This should work for you w/ simple form <%= f.input :source_type, :label => "Lead or VTeam", :collection => ["lead","vteam"], :selected => "lead" %> Hope this helps 来源: https://stackoverflow.com

Integration of simple_form with bootstrap 3

那年仲夏 提交于 2019-12-03 09:49:49
问题 I've updated bootstrap to version 3. Everything works fine except the forms which are generated by simple_form gem. I don't know how could I integrate these two together. I can't find any helpful suggestion in the github project repository either. So does anyone have a solution for me ? 回答1: There's a blog post here http://stabco.tumblr.com/post/59760641051/simple-form-bootstrap3-integration that looks like a good solution. It updates the initializer to suit bootstrap 3. 回答2: This gist was

how to add a class to the input component in a wrapper in simple_form 2

牧云@^-^@ 提交于 2019-12-03 08:58:47
问题 I am trying to have class="text" in my input fields when using a custom wrapper called :hinted in simple_form 2.0.0.rc config.wrappers :hinted do |b| b.use :input, :class => "text" end but the output doesn't have that class, I tried :wrap_with => {:class => 'text'} to no avail Does anyone know how this is done? Thank You! 回答1: Currently there no way to do this. You can use the defaults options like this if you want. <%= simple_form_for(@user, :defaults => { :input_html => { :class => "text" }

Nested Simple Form in Rails4 - has many through, save multiple records

巧了我就是萌 提交于 2019-12-03 08:48:05
I've got a standard has_many through relationship. Humans have many Orcs through a join table Interactions. The interactions is just a table and model; no controller or views. Using the simpleform gem in Rails 4, I want to make a form from the humans page, in order to select multiple orcs out of the pool of all orcs. Once submitted, I want it to create/update as many records in the interactions table, each with the human id, and as many orc ids were selected. : AKA list notation Make a form from one end (humans) List out all the orcs in the form Select multiple orcs from that list Save as many

simple_form custom input with custom wrapper

馋奶兔 提交于 2019-12-03 08:21:45
问题 I'm trying to make a custom input for currency in my app. I had those bootstrap wrappers and etc (I think it comes with simple_form or with bootstrap gem...), so, I could do something like: <%= f.input :cost, wrapper => :append do %> <%= content_tag :span, "$", class: "add-on" %> <%= f.number_field :cost %> <% end %> And it works just as expected. The thing is: I need this same thing in a lot of places, and I don't want to copy/paste it all around. So, I decided to create a custom input.

Default value for input with simple_form

一个人想着一个人 提交于 2019-12-03 08:03:52
问题 im trying to do default value for input works ok: <%= f.input_field :quantity, default: '1' %> but i need f.input not f.input_field <%= f.input :quantity %> im trying it with standard html value - but after unsucessfull validation quantity is overriden by 1 - undesired <%= f.input :quantity, input_html: {value: '1'} %> when i remove value and validation is unsucessfull quantity is populated - everything is ok <%= f.input :quantity %> how to solve this ? is there any alternative like in f

Rails 3 polymorphic association with Carrierwave and Simple Form

允我心安 提交于 2019-12-03 08:02:01
问题 I'm trying to set up a polymorphic association for photo uploads which are processed using Carrierwave. I'm using Simple Form to build my forms. I feel like the association is correct so I'm wondering if my problem is just something with the form or controller. Here are my associations: property.rb: class Property < ActiveRecord::Base attr_accessible :image ... has_many :image, :as => :attachable ... end unit.rb class Unit < ActiveRecord::Base attr_accessible :image ... has_many :image, :as =

How do I get rid of the div that wraps every input in a simple_form?

自古美人都是妖i 提交于 2019-12-03 07:13:27
This input: <%= f.input :keywords, label: false, :input_html => {:class => "span8"}, :placeholder => "Park Slope, Prospect Heights, Fort Green..." %> Produces this: <div class="control-group string optional"> <div class="controls"> <input class="string optional span8" id="search_keywords" name="search[keywords]" placeholder="Park Slope, Prospect Heights, Fort Green..." size="50" type="text" /> </div> </div> How do I just generate the input alone without the divs around it? Thanks. Viren Well do something like this pass a params wrapper: false like this <%= f.input :keywords, label: false,

Simple_form: Remove outer label for an inline checkbox with label

断了今生、忘了曾经 提交于 2019-12-03 06:34:40
问题 Using Simple_form 2.0.2 The simple form code using HAML: = f.input :remember_me, as: :boolean, inline_label: 'Remember me' But it renders this: <div class="control-group boolean optional"> <label class="boolean optional control-label" for="admin_remember_me">Remember me</label> <div class="controls"> <input name="admin[remember_me]" type="hidden" value="0" /> <label class="checkbox"><input class="boolean optional" id="admin_remember_me" name="admin[remember_me]" type="checkbox" value="1" /

Displaying simple_form error messages in top <div>

别等时光非礼了梦想. 提交于 2019-12-03 05:13:35
I have the following two _forms: user form <%= simple_form_for(@user, :url => @target) do |f| %> <% if @user.errors.any? %> <div id="error_explanation"> <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2> <ul> <% @user.errors.full_messages.each do |msg| %> <li><%= msg %></li> <% end %> </ul> </div> <% end %> <%= f.input :email, :label => "User Email" %> <%= f.input :password, :label => "User Password" %> <%= f.input :first_name %> <%= f.input :last_name %> <%= f.button :submit %> <% end %> tenant form <%= simple_form_for(@tenant, :url => @target) do |f