simple-form

can't change the height of a text field in simple_form

ぃ、小莉子 提交于 2019-12-21 07:23:58
问题 I've tried #Default size for text inputs. config.default_input_size = 10 from config/initializers/simple_form.rb I've also tried <%= f.input :message, :input_html => {:size => 10} %> But neither of these change a single thing about how my text fields appear. 回答1: You need to do this <%= f.input :message, :input_html => {:rows => 10} %> Html text area tag attributes has two attributes namely rows and cols which lets you specify the no of rows and columns(i.e. width) of your text area. If this

Min value for input in Simple Form

非 Y 不嫁゛ 提交于 2019-12-21 06:59:58
问题 I want to create a simple money input with SImpleForm. So the money field should have a minimum value which is 0, so that user cannot enter value less than 0. However I don't know how to define min value with simple form. I wonder if it's possible. 回答1: Definitely! The (simplified) HTML for the form you want looks something like this: <form> <input type="number" min="0" step="any" name="amount"> </form> Notice the two really important properties on the input field: min is set to 0, because

Rails : simple_form : Getting an empty string from checkbox collection

你说的曾经没有我的故事 提交于 2019-12-21 06:51:08
问题 I have the following code in my views <%= f.input :role_names, as: :check_boxes, collection: @program.role_names %> And whenever I submit the form I am getting values something like ["admin, "moderator", ""] but I was expecting something like ["admin, "moderator"] , why is this? Moreover I made a inspect element, and there was a <input name="user[role_names][]" type="hidden" value=""> tag after the last check box, within the same control-group. I suppose this is getting added at the last in

File upload field causing ActionController::InvalidAuthenticityToken exception

若如初见. 提交于 2019-12-21 06:48:48
问题 Using rails 4, and trying to add a file field to an existing form, using simple_form and paperclip. Here's the critical part of the form: <%= simple_form_for(@employee, html: { class: 'form-horizontal requires', multipart: true}, remote: true) do |f| %> <%= f.input :avatar %> <% end %> Everything works ok, unless I actually submit the form with an uploaded file. Then, I get this: ActionController::InvalidAuthenticityToken in EmployeesController#update What am I doing wrong here? 回答1: The

Creating inline date_select dropdowns using simple_form and zurb foundation

放肆的年华 提交于 2019-12-21 04:08:11
问题 I'm using Simple_Form with Zurb Foundation in my rails application. One of more views has a form with the following date_select The form fields are showing up stacked rather than inline. I've checked everything and can't figure out how to get these to show-up correctly. What am I missing? You can see the repo at https://github.com/stanrails/momtomom in the event.html.erb view. The code for the section is below: <div class="row"> <div class="small-5 columns"> <%= f.date_select :eventDate %> <

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

戏子无情 提交于 2019-12-21 02:53:10
问题 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

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

£可爱£侵袭症+ 提交于 2019-12-21 02:21:13
问题 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. 回答1: Well

How to use placeholders instead of labels in simple_form?

让人想犯罪 __ 提交于 2019-12-18 14:07:14
问题 I want to use placeholders everywhere in my application instead of labels. I am using simple_form and Rails (3.2.14). How can I specify in simple_form config file to use placeholders instead of labels. In Initializers there is a file simple_form.rb ie # Use this setup block to configure all options available in SimpleForm. SimpleForm.setup do |config| # Wrappers are used by the form builder to generate a # complete input. You can remove any component from the # wrapper, change the order or

How to use placeholders instead of labels in simple_form?

瘦欲@ 提交于 2019-12-18 14:06:10
问题 I want to use placeholders everywhere in my application instead of labels. I am using simple_form and Rails (3.2.14). How can I specify in simple_form config file to use placeholders instead of labels. In Initializers there is a file simple_form.rb ie # Use this setup block to configure all options available in SimpleForm. SimpleForm.setup do |config| # Wrappers are used by the form builder to generate a # complete input. You can remove any component from the # wrapper, change the order or

How do I add HTML attributes to select options with Simple Form Rails?

有些话、适合烂在心里 提交于 2019-12-18 12:13:57
问题 I need to add a custom HTML attribute to each option for a select control. I'm using simple_form in Rails. Does anyone know how to do this? The attribute will be consumed by client-side JS. For instance, I want to do something like this: <%= f.input :group, collection: @groups, option_html: { data-type: lambda { |g| g[2] } } %> Which would produce (simplified): <select> <option value="1" data-type="primary">First Group</option> <option value="2" data-type="secondary">Second Group</option>