simple-form

Simple_form how to make accept terms checkbox inline

♀尐吖头ヾ 提交于 2019-11-29 13:07:27
问题 <p><%= f.input :terms, :as => :boolean, :label => false, :boolean_style => :inline %> Accept <%= link_to "Terms of use", terms_path,:remote => true %> and <%=link_to "privacy Policy", privacy_path, :remote => true%></p> It ends up looking like this What is the best way to line them up on the same line. 回答1: Here's a rather simple way: <%= content_for(:the_links) do %> Accept <%= link_to "Terms of use", terms_path,:remote => true %> and <%=link_to "privacy Policy", privacy_path, :remote =>

Rails 4 + simple_form and jQuery UI. Datepicker is not working via turbolinks

こ雲淡風輕ζ 提交于 2019-11-29 13:05:46
问题 I have this form which calls datepicker: ... <%= f.input :expiration_date, as: :datepicker, required: false %> ... Simple_form wrapper: app/inputs/datepicker_input.rb class DatepickerInput < SimpleForm::Inputs::Base def input @builder.text_field(attribute_name, input_html_options) + \ @builder.hidden_field(attribute_name, { :class => attribute_name.to_s + "-alt"}) end end When the page is loaded from scratch ( $(document).ready event ), the following html is generated: <input class=

simple_form's collection_radio_button and custom label class

孤者浪人 提交于 2019-11-29 09:33:24
问题 I'm trying to make a star rating form with radio collection using FontAwesome, for this I actually need to change the label classes of the collection_radio_button input generated by simple_form but can't find any obvious solution. So far I use: form_for @user do |f| f.collection_radio_buttons :rating, [[1, 'Bad'] ,[2, 'Ok'], [3, 'Great']], :first, :last, { item_wrapper_tag: false } end Which generates: <input id="review_rating_1" name="review[rating]" type="radio" value="1" /> <label class=

Cocoon add association, how to limit number of associations

佐手、 提交于 2019-11-29 07:21:35
I am creating a system that stores cards using Ruby/Rails/HAML - In this case there is a Card class that has many Colours (this is also a class). When creating and editing a card I am using the Cocoon gem to allow me to dynamically add colour associations. The problem I am having is that in the Card model, a card is limited to having a maximum of 5 colours. Yet the interface allows adding of unlimited colours resulting in an error. Is there a way in Cocoon to limit the number of associations that can be added to a form, so that this limit is not exceeded? This is the code for a form to add

Bootstrap datepicker default value simple_form_for

六月ゝ 毕业季﹏ 提交于 2019-11-29 05:09:28
I am using the bootstrap date picker to enable selection of dates in a form using simple_form_for. For example <%= f.input :payment_date, as: :string, input_html: { class: "datepicker" } %> My date picker uses the format of dd-mm-yyyy I would like to set today's date as the default value in the form using simple_form_for, any ideas on how I can do that? juanpastas <%= f.input :payment_date, as: :string, input_html: { class: "datepicker", value: Time.now.strftime('%d-%m-%Y') } %> Another format to it is: (working with active admin gem) f.input :date, as: :date_picker, :input_html => { :value =>

Display inline errors with simple_form in a Bootstrap Ajax modal

Deadly 提交于 2019-11-29 04:47:02
I've found similar StackOverflow questions here and here but still can't get this to work. I'm using Rails 3.2.8, SimpleForm 2.0.4, and Twitter Bootstrap 2.1.1 (via the bootstrap-sass gem 2.1.1.0). The user should be able to add a contact from a modal popup window. If there are validation errors, they should appear inline, just as if the user were using a non-modal version of the form (red border around field, error message next to field). I load the modal like this: <a data-toggle="modal" data-target="#new-contact-modal">Go modal!</a> Here is the Bootstrap modal, which calls the same contacts

Align checkboxes for f.collection_check_boxes with Simple_Form

两盒软妹~` 提交于 2019-11-29 03:53:31
I am using RoR and I am using the Simple_Form gem for my forms. I have an object relation whereby a User can have multiple Roles, and during creation, the admin can select which Roles to apply to the new User. I would like the Roles to have their checkbox on the left, and their name on the right in a horizontal arrangement. // "box" Admin // instead of the current // "box" Admin // My current code to show the Roles is this. <div class="control-group"> <%= f.label 'Roles' %> <div class="controls"> <%= f.collection_check_boxes :role_ids, Role.all, :id, :name %> </div> </div> The part I am most

Ruby on Rails 4 - simple_form multiple select input

社会主义新天地 提交于 2019-11-29 03:04:46
I have a simple_form input field that looks like this: <%= f.input :particular_users, collection: @all_users, input_html: { class: 'multiselectuser', multiple: true} %> When I leave multiple: true off, the form submits the chosen value for the parameter :particular_users and I can see the value when debugging using "raise params.inspect". However when I leave the multiple: true option there, no vales get passed for the parameter :particular_users. What am I doing wrong? EDIT: I can not use the association input because :particular_users is a virtual attribute and has no relationship. I want

How to set default selected value for Rails SimpleForm select box

情到浓时终转凉″ 提交于 2019-11-29 02:50:58
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 work. TIA Use the following: selected: 1 You can now use the following: <%= f.association :store, selected: 1 %> 来源: https://stackoverflow.com/questions/10441061/how-to-set-default-selected-value-for-rails-simpleform-select-box

add checkbox with simple_form without association with model?

徘徊边缘 提交于 2019-11-29 02:27:25
问题 How I can add checkbox with simple_form without association with model? I want to create checkbox which will handle some javascript events, but don't know? Maybe I miss something in documentation? Want't to use similar like following: = simple_form_for(resource, as: resource_name, url: session_url(resource_name), wrapper: :inline) do |f| .inputs = f.input :email, required: false, autofocus: true = f.input :password, required: false = f.input :remember_me, as: :boolean if devise_mapping