Questions tagged [simple-form]

Questions about "Simple Form" which generates view code for forms in Rails. This tag is NOT related to "SimpleForm" in OpenUI5.

According to simpleform on github

SimpleForm aims to be as flexible as possible while helping you with powerful components to create your forms. The basic goal of simple form is to not touch your way of defining the layout, letting you find the better design for your eyes.

SimpleForm borrows syntax from the Formtastic gem, and aims to be a more lightweight alternative.

For more details, see:

https://github.com/plataformatec/simple_form/

http://blog.plataformatec.com.br/tag/simple_form/

SimpleForm was covered in railscast episode #234

2835 questions
181
votes
5 answers

rails simple_form - hidden field - create?

How can you have a hidden field with simple form? The following code: = simple_form_for @movie do |f| = f.hidden :title, "some value" = f.button :submit results in this error: undefined method `hidden' for…
85
votes
6 answers

SimpleForm without for (non model form)

Is it possible to use Simple Form (by: Plataformatec) without a model? https://github.com/plataformatec/simple_form
Edward Ford
  • 1,631
  • 3
  • 13
  • 25
75
votes
5 answers

rails simple_form fields not related to the model

I have an existing form which is tied to a model named 'Order', but i want to add new form fields that will capture Credit Card info such as name, cc number, etc to be processed on a 3rd party payment gateway. But since i don't want to save CC info…
zeratool
  • 1,271
  • 2
  • 12
  • 17
64
votes
6 answers

Default value for input with simple_form

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…
patie
  • 1,074
  • 1
  • 10
  • 18
58
votes
2 answers

rails, simple_form, how to set selected index of a collection when page loaded?

I am using simple_form gem, I have a countries collection, it work fine when I select the country, and updated record will have the country id stored, but, when I try to edit the record, the chosen country is not selected by default at edit…
simo
  • 23,342
  • 38
  • 121
  • 218
55
votes
1 answer

How to define action with simple form for?

I am trying to define the action "savenew" in admin/photographers controller. I have tried this: <%= simple_form_for(:photographer_savenew, :action => 'savenew', :id => params[:id], :multipart => true ) do |f| %> But the action in the form is…
Rails beginner
  • 14,321
  • 35
  • 137
  • 257
42
votes
11 answers

Rails: How to disable asterisk on form's required fields?

When I add the 'Required' attribute to html input fields, Rails pre-pends an asterisk (*) before the label. Does anyone know how to prevent this? For some reason Rails transforms this: <%= f.input :Company, :input_html => {:value => "", :id =>…
vsync
  • 118,978
  • 58
  • 307
  • 400
41
votes
2 answers

simple_forms custom data attribute

I would like to have an additional data attribute on an input tag generated by simple_form. The following does not work: <%= f.input :date, :as => 'date_picker', :data => {:datepicker => :datepicker} %> How could this be done? Is it possible at…
Ynv
  • 1,824
  • 3
  • 20
  • 29
40
votes
4 answers

Does form_tag work with Simple_form?

I have a form that is using form_tag and not sure how to use it with the simple_form gem. This is how my form looks: <%= form_tag create_multiple_prices_path, :method => :post do %> <% @prices.each_with_index do |price, index| %> <%=…
LearningRoR
  • 26,582
  • 22
  • 85
  • 150
39
votes
2 answers

Simple form association custom label name

I have been struggling with what I perceive to be a simple problem: Working in Rails 3.0.8 with the simple_form 1.4 gem. I have two models, owners and owner_types; class Owner < ActiveRecord::Base belongs_to :own_type attr_accessible :name,…
dj_44
  • 395
  • 1
  • 3
  • 5
39
votes
2 answers

How to set default selected value for Rails SimpleForm select box

I'm trying to figure out how to set the selected option of a select box generated by SimpleForm. My code is along the lines of: <%= simple_form_for(@user) do |f| %> <%= f.association :store, default: 1 %> Of course the default: 1 part does not…
Eric
  • 3,773
  • 3
  • 29
  • 29
38
votes
6 answers

Simple_form: Remove outer label for an inline checkbox with label

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:
36
votes
5 answers

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

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…
YWCA Hello
  • 2,997
  • 4
  • 29
  • 40
36
votes
5 answers

HTML code inside buttons with simple_form

I'm new to rails, and just found the simple_form gem. I installed it with bootstrap suport, but now I can't get this code to work the way I want it <%= f.button :submit, " Save", class: "btn btn-primary" %> I just…
Bruno Campos
  • 2,188
  • 1
  • 20
  • 34
35
votes
2 answers

Change id in simple form

How change default id or class, which produce simple form: = simple_form_for(@account, url: account_url, validate: true, wrapper: :inline, html: { method: :put }) do |f| html:
Mikhail Grishko
  • 4,258
  • 3
  • 22
  • 21
1
2 3
99 100