simple-form

Change only the image inside same div when option from dropdown is chosen

血红的双手。 提交于 2019-12-23 03:12:33
问题 I have a nested form where you can add new bracelets to your order. For each bracelet you can choose a color, and next to the select (dropdown) where you choose the color there is an image with the bracelet on that color. The problem is this: When I add a new nested-fields div (form for new bracelet), when I select a color in the dropdown the image next to it doesn't change. Also, when I select a color in the dropdown for the first bracelet, the images for all the bracelets change to that

nested model attributes + wicked wizard form not working

你说的曾经没有我的故事 提交于 2019-12-23 02:17:26
问题 I am making an app based on the railscast tutorial 346(Wicked gem) and 196(nested model). I am trying to combine these 2 together and I am stuck because strong param attributes are not saving. So my app goes like this: I have a user, work, and education model. user.rb: has_many :educations, dependent: :destroy has_many :works, dependent: :destroy accepts_nested_attributes_for :educations, :works education.rb belongs_to :user work.rb belongs_to :user And then i generated the wicked wizard

simple_form and hstore basic functionality

两盒软妹~` 提交于 2019-12-22 18:15:33
问题 I can get hstore to work with simple_form but all but the most basic functionality (saving) just doesn't work. Validation messages don't show up on the individual fields... all hstore fields oddly show as required, even the values themselves don't populate correctly unless set manually. I have to do something like this: <%= f.simple_fields_for :phones do |phone| %> <%= phone.input :agent, :input_html => { :value => @artist.phones['agent'] } %> <% end %> I have to use simple_fields_for for the

Add a class to each select options with SimpleForm

送分小仙女□ 提交于 2019-12-22 09:57:47
问题 I want to build a select input from an array (and not a collection of models), with SimpleForm, and have different classes for each option s. I would have hoped that this would work: f.input :method, collection: [ ["option text", "option_value_1", { class: "class_name_1" }], ["option text 2", "option_value_2", { class: "class_name_2" }] ] The problem with that is it will generate: <select> <option value="option text" class="class_name_1">option text</option> <option value="option text 2"

simple form collection translation

浪子不回头ぞ 提交于 2019-12-22 08:51:36
问题 Using the translation example here that translates the :male, :female options using Ruby I18n, the form will be: View: _form.html.erb <%= f.input :gender, collection: [:male, :female] %> Generated HTML: <option>Male</option> <option>Female</option> So when submitting, the form uses the translated values. How can I change the view code to submit ["male", "female"] values instead of ["Male", "Female"]? My best shot so far is pretty ugly: <%= f.input :gender, collection: [:male, :female].map{|v|

simple_form collection labels

牧云@^-^@ 提交于 2019-12-22 01:56:26
问题 I want to use labels for collection items (for example, their translations). = simple_form_for(@client) do |f| = f.error_notification .form-inputs = f.input :name, label: t('client.name') = f.input :level, collection: ['a', 'b', 'c'], label_method: ???? label: t('client.level') .form-actions = f.button :submit, value: t('client.submit') I am trying to figure out, what to use for label_method above. I would like to have label_method to map to translations as in map {|s| t("client.#{s}")} . 回答1

Searchable drop down list for rails 3.2.8?

自作多情 提交于 2019-12-22 01:10:48
问题 On new order form, a user needs to select a customer from a drop down list which contains dozens of customers and is hard to find and select by scrolling up and down. That's why we want to build a searchable drop down list . When a user enter a few letters of customer's name, the drop down list filters out all others and is left with only the names of the customers containing the letters just keyed in. We are using simple_form and rails 3.2.8 . One way we can do is to add a text box for

Parsing JSON errors using simple_form and AJAX in rails

别来无恙 提交于 2019-12-22 00:40:34
问题 I have a form that is using Simple Forms and remote => true on the users dashboard (which is handled by a dashboard view and dashboard controller). The form allows a user to add a custom game rule; however, it's loading the form via a Jquery's .load() function. The form is loading from the "rules" view (handled by a rules controller). When the user clicks the submit button, I'm not getting any error validation. Her is the create action on the rule controller: def create @rule = Rule.new

How to generate a radio-inline label with simple_form and bootstrap?

女生的网名这么多〃 提交于 2019-12-21 17:40:01
问题 I'm using: <%= simple_form_for @visitor, html: {class: 'form-inline'} do |f| %> <%= f.error_notification %> <%= f.input :favorite, label: false, as: :radio_buttons %> <%= f.submit "Choose!", :class => "btn btn-primary"%> <% end %> And I get this html: <div class="control-group radio_buttons required visitor_favourite"> <div class="controls"> <label class="radio"> <input class="radio_buttons required" id="visitor_favourite_true" name="visitor[favourite]" type="radio" value="true" /> Yes <

Converting String to Date before save with Rails

谁说胖子不能爱 提交于 2019-12-21 08:49:29
问题 Very new to Ruby and I've been stuck for hours. Searching everywhere and can't find an answer. So I'm using the bootstrap datepicker for rails gem. Because I've changed the date format of the datepicker, it won't store in the DB. Guessing this is because the simple_form input is being used as a string to avoid the default date selection inputs applied by simple_form. My question is: How do I modify/convert a string like "06/18/2013" to a date before it is saved to the db? Is this best handled