simple-form

Default disable_with for simple_form submit

好久不见. 提交于 2020-01-02 03:42:08
问题 I want to change the default behavior of my submit button in simple_form so that I needn't explicitly specify :disable_with => true for all my forms. How can I make this particular change in the simple_form.rb? 回答1: This is a little different in newer versions of Rails, as setting the property disable_with is deprecated. I wrote an article on this: http://www.railsonmaui.com/blog/2014/02/23/simple-form-and-disable-processing-by-default/ Here's the new code: SimpleForm::FormBuilder.class_eval

SimpleForm+ClientSideValidations+bootstrap - Validation is not occuring on the form- all inputs are accepted

自闭症网瘾萝莉.ら 提交于 2020-01-01 09:26:07
问题 I am using the SimpleForm, ClientSideValidations, and ClientSideValidations-SimpleForm gems in a RoR application. I can render the form into the modal beautifully, however when the input loses focus no validation occurs and the form is submitted. Also note that I have tried using the fix found here: http://www.ddarrensmith.com/blog/2012/05/17/ruby-on-rails-client-side-validation-with-validation-helpers-and-twitter-bootstrap/ Segment of the view containing the form: <div class='modal hide' id=

Displaying simple_form error messages in top <div>

萝らか妹 提交于 2020-01-01 02:25:06
问题 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

Append/prepend bootstrap icons with simple_form

做~自己de王妃 提交于 2019-12-31 08:36:06
问题 Twitter Bootstrap icons are pretty deadly seen here. Look at the bottom right hand corner of that section. See that email with an icon prepended? That is what I want to do. I want to make simple_form and boostrap play nicely. Here's what I've found that will prepend the icon to the input: = f.input :email, :wrapper => :append do = f.input_field :email <span class="add-on"><i class="icon-envelope"></i></span> But it isn't flush (that could be fixed by changing offsets in CSS) and it's pretty

Deep Nested Rails 4 Form

烈酒焚心 提交于 2019-12-30 03:14:18
问题 I have 3 models Item which accepts nested attributes for questions and questions accept nested attributes for answers. I'm trying to create an item which has a question and an answer in the same form. item.rb class Item < ActiveRecord::Base has_many :questions, dependent: :destroy accepts_nested_attributes_for :questions end question.rb class Question < ActiveRecord::Base belongs_to :item has_many :answers, dependent: :destroy accepts_nested_attributes_for :answers end answer.rb class Answer

Changes in the form are not saved to database

自古美人都是妖i 提交于 2019-12-28 09:38:40
问题 I'm trying to add a date field to my form. I added bootstrap-datepicker-rails gem, all required css and javascript. When I choose the date in the calendar and click Save, it's not updated in the database. Here's the code of the form: = simple_form_for @model = f.input :date_last, :required => true, :input_html => { data: {behaviour: "datepicker"}}, :as => :string = f.button :submit, 'Save', :class => 'btn btn-primary' I think this might have to do with formats, but not sure where to look at.

Rails Simple Form custom association select field

本小妞迷上赌 提交于 2019-12-28 05:44:05
问题 I have a select field and I want to put a custom attribute at it called name, I tried to do it like that: <%= f.association :in_charge, :collection => User.lawyer.map{ |l| [l.name, l.id, {:name => l.name.downcase}] } %> It works and generates the extra attribute but there is a problem, the select value attribute get changed to the model name attribute, in this case l.name. I changed places and put l.id first but the id attribute is displayed, they get duplicated, any idea why that happens? Is

Rails and carrierwave uploading multiple images fails

痞子三分冷 提交于 2019-12-25 08:34:56
问题 Hello I have a form where I could write some articles, with a title, a content, a main_image, they all come from the same model progress In this same form I have another field from another model progress_attachment I use it to upload multiple images. ( I used carrierwave, and SSR solution as exemple) It works for title date content main image ! But the field with multiple file upload ony allows one image... it should accept multiple... What's wrong? So here is my form: = simple_form_for(

How to submit two forms with one submit button with rails and javascript

六月ゝ 毕业季﹏ 提交于 2019-12-25 05:09:50
问题 I need to allow a user to type up a comment and submit before asking them to provide account details. Once these details are provided, they are used to create a new user and the comment they wrote is also submitted and belongs to this new user. Currently, I simply can't figure out how to trigger the submit action on both forms, passing all the information to the server to carry these tasks out. Basically what I want: User writes up a comment, submits Submit button displays a contact info form

Simple_Fields_For: Multiple Blank Lines on a Form

≯℡__Kan透↙ 提交于 2019-12-25 03:19:15
问题 I am trying to get a number of blank lines on a simple form using simple_fields_for but only one line/record displays. This is the code below, the models, controller, and view. class Journal < ActiveRecord::Base has_many :journal_lines end class JournalLine < ActiveRecord::Base belongs_to :journal end class JournalController < ApplicationController def new @organisation = Organisation.find(params[:organisation_id]) @journal = Journal.new @journal.journal_lines = Array.new(5, JournalLine.new)