Questions tagged [simple-form-for]

Syntax for generating a Rails simple_form component

Note: This tag is a synonym of https://stackoverflow.com/questions/tagged/simple-form and should probably be deleted on that basis.

177 questions
9
votes
2 answers

simple_form - override default input "type" mapping

simple_form is generating "type='number'" on the input field for any integer attribute, instead of type='text'. As this causes Chrome to show a counter control, I'd rather make it just use type='text' as the default for numbers. It seems to be…
mahemoff
  • 38,430
  • 30
  • 133
  • 196
7
votes
1 answer

How can I set timezone in simple form datetime field?

I have a model with a datetime field, and is stored in UTC, how can I display that date in simple form gem in a specific timezone? Already tried with the option input_html: {value: @model.date.in_time_zone('Eastern Time (US & Canada)')} Note: I…
letz
  • 1,610
  • 1
  • 19
  • 36
6
votes
3 answers

Rails simple_form create form when column type is JSON

I have a model (FooBar) with three columns: Foo -> String Bar -> JSON Baz -> String I want to create a form for this model Bar has default attributes of: {zing: {}, zaz: {}, laz: {}} I would like to have the following inputs: f.input :foo f.input…
stytown
  • 1,412
  • 2
  • 14
  • 22
6
votes
3 answers

How to display validation error messages with Simple_form but without model?

I use Simple_form in my Rails 4 application. How can I display error messages in a view that is not tied to a model ? I want to have the same result than in other views based on models. For now, this is the code in the view : <%=…
Fred Perrin
  • 1,084
  • 2
  • 17
  • 23
4
votes
1 answer

Error messages of nested attributes's required field are not displayed

In my case, I have a client who has many tasks (which requires :detail and :completion_date fields.). I've been building a nested model form like the following: = simple_form_for @client do |f| = f.simple_fields_for :tasks do |task| =…
3
votes
2 answers

How to use Bootstrap's input group in simple_form gem

Environment Ruby 2.5.1 Rails 5.2.1 Simple Form 4.0.1 Current behavior I follow example in http://simple-form-bootstrap.plataformatec.com.br/examples/input_group I start with <%= simple_form_for app, wrapper: :input_group do |f| %> and get Couldn't…
sarunw
  • 7,448
  • 10
  • 43
  • 76
3
votes
2 answers

individual simple_form radio button

I am using SimpleForm 3.2.1 with Rails 4. I am trying to convert a rails form into a simple_form. Here is the code that works for radio buttons with the regular rails form:
    <%…
Philip7899
  • 4,189
  • 2
  • 44
  • 99
3
votes
2 answers

Rails 4 - Display choices as radio buttons

I am working on a Rails 4 application, using simple_form for input. There are several model fields that can take well-known answers or a free-form answer. For example, for a field fruit:string I would like to display "Apple", "Banana", "Other". If…
2
votes
2 answers

Empty array value being input with simple_form entries

I'm still new to rails and simple_form and have been trying to implement a multiple select option to give a user multiple roles. Current input looks like this <%= f.input :secondary_role, :collection => UseridRole::VALUES, :include_blank =>…
s89_
  • 915
  • 1
  • 11
  • 25
2
votes
2 answers

simple form and form object - one form for new and edit

I was trying to find the answer for the following question, but I failed. I am creating simple_form with Form Object, and I don't know what URL should I specify in simple_form in order to reuse the same form for new and update actions. Here is my…
Rigi
  • 1,630
  • 1
  • 5
  • 16
2
votes
1 answer

Rails 5.1 - How nested 2 models inside form for - between a normal table and a polymorphic one?

My target is to create a project instance and also its nested attributes for credits (polymorphic table) inside one single form. ⚠️ "error param is missing or the value is empty: credit" ⚠️ I can't find the correct syntax to provide the instance…
2
votes
3 answers

Params hash from a SimpleForm with multiple records has a different structure for one record than for two

I struggled to digest this into a title. I'm using SimpleForm to construct a bulk-edit page with one or more fieldsets - one for each record in a collection of ActiveRecord models that have been built but not yet saved. My form looks like this: =…
Jacob
  • 552
  • 3
  • 22
2
votes
0 answers

SimpleForm gem (Radio gives error, checkboxes work)

Why would SimpleForm give an error for a radio and not a checkbox? Check box works <%= f.association :color, :as => :check_boxes %> Radio gives error <%= f.association :color, :as => :radio %> error No input found for radio
user2012677
  • 4,475
  • 4
  • 27
  • 70
2
votes
2 answers

Module route in Rails with form_for(@object)

I have namespaced Controller Entities::Customers class Entities::CustomersController < ApplicationController ... end and namespaced ActiveRecord model: class Entities::Customer < Entities::User end in my routes.rb file i have: resources…
2
votes
2 answers

Rails simple form undefined method `model_name' for nil:NilClass

I want to create a simple form to make new reviews for a recipe that has been posted in a cookbook. I render the review form on the recipe show page, but it keeps giving me the same error: undefined method `model_name' for nil:NilClass When I do not…
Seifer
  • 197
  • 2
  • 9
1
2 3
11 12