simple-form

simple_form renders radio buttons incorrectly

与世无争的帅哥 提交于 2019-12-01 11:58:19
Using simple_form I render some radio buttons to select Gender on registration page. code: = f.input :gender, :collection => gender, :as => :radio_buttons, :item_wrapper_class => 'inline' This gives output like: Is there a way to make the first radio button be behind Male and the 2nd radio button behind Female? Here is a better solution than my original below. From the code: # form_for @user do |f| # f.collection_radio_buttons( # :options, [[true, 'Yes'] ,[false, 'No']], :first, :last # ) do |b| # b.label { b.radio_button + b.text } # end # end I think this is what you are looking for: <%= f

Manually set the ID's of form input fields in a simpleform form?

限于喜欢 提交于 2019-12-01 10:51:00
Is it possible to overrule simpleform's naming of textfields within a form? This: = f.input_field :age_from, Outputs in: <input type="text" size="50" name="/people/search[query]" id="_people_search_query"> Should be <input type="text" size="50" name="/people/search[query]" id="query"> I tried * :name => "query" * :id => "query" to no avail Like your other question html options should be passed in input_html hash in simple_form: <%= f.input :age_from, ..., :input_html => { :id => 'my_id' } %> should work. I think you need to pass it in the html attribute hash html: {id: 'query'} 来源: https:/

simple_form renders radio buttons incorrectly

孤街浪徒 提交于 2019-12-01 09:57:58
问题 Using simple_form I render some radio buttons to select Gender on registration page. code: = f.input :gender, :collection => gender, :as => :radio_buttons, :item_wrapper_class => 'inline' This gives output like: Is there a way to make the first radio button be behind Male and the 2nd radio button behind Female? 回答1: Here is a better solution than my original below. From the code: # form_for @user do |f| # f.collection_radio_buttons( # :options, [[true, 'Yes'] ,[false, 'No']], :first, :last #

Manually set the ID's of form input fields in a simpleform form?

試著忘記壹切 提交于 2019-12-01 09:42:07
问题 Is it possible to overrule simpleform's naming of textfields within a form? This: = f.input_field :age_from, Outputs in: <input type="text" size="50" name="/people/search[query]" id="_people_search_query"> Should be <input type="text" size="50" name="/people/search[query]" id="query"> I tried * :name => "query" * :id => "query" to no avail 回答1: Like your other question html options should be passed in input_html hash in simple_form: <%= f.input :age_from, ..., :input_html => { :id => 'my_id'

Change id in simple form

ぐ巨炮叔叔 提交于 2019-12-01 02:06:25
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: <form accept-charset="UTF-8" action="http://mikhail.smackaho.st:3000/account" class="edit_account" data-validate="true" id="edit_account_4f15c0a487f4463d8d000004" method="post" novalidate="novalidate"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"><input name="_method" type="hidden" value="put"><input name="authenticity_token" type="hidden" value="BZFZUGlbZU2ILGR

setting target _blank for just one form submit action

喜你入骨 提交于 2019-12-01 00:23:01
问题 I'm submitting a form to my rails app, with two submit buttons. They both go to the same controller action, and use the same form, but on one submit action i want to make the form target=_blank so that the form submission results open in a new window. Is there an easy way to do this? Doing this works for both actions: <%= simple_form_for @thingy, :target => '_blank' do |f| %> I've mucked around with using jQuery to set the target on the form onclick , but with no luck. 回答1: On one of the

Formatting a date input using simple_form

不问归期 提交于 2019-11-30 23:40:19
问题 I have a date type field in my database. Here's the view code I'm using: # Using 'as: :string' to avoid those three dropdowns rails generates. = f.input_field :start_date, as: :string, class: 'form-control datepicker' When saving a date I use a jquery plugin that shows a calendar and writes in a date like: 11/05/2013 . But when editing the same record, the input is populated with a value 2013-05-11 . How can I make it so simple_form actually respects my date format defined in en.yml ? 回答1:

Show full error messages with simple form?

拈花ヽ惹草 提交于 2019-11-30 22:50:24
How do I output the full error message of a field using simple form? The equivalent of rails: <%= RESOURCE.errors.full_messages %> e.g. show this: "Email has already been taken", "Password confirmation doesn't match Password", "Password is too short (minimum is 8 characters)" instead of: f.error_notification "has already been taken", "doesn't match Password", "is too short (minimum is 8 characters)" simple_form (3.0.2)/Rails 4.1.1 If anyone is still wondering there is an easy way to do this now, as referenced here Simply under config/initializers/simple_form.rb change b.user :error to b.user

Rails acts-as-taggable-on with select2 (and simple_form)

落花浮王杯 提交于 2019-11-30 21:29:35
I would like to have a select2 dropdown of tags, where i could select multiple existing tags and add new ones. I have tried many different ways and i either don't get select2 box working or only one value is passed (last one). This is closest i got (passes last value): <%= f.input :tag_list, collection: @model.tags.map { |t| t.name }, input_html: { :style=> 'width: 300px', class: "taggable", data: { placeholder: "Tags" }} %> As I mentioned before, normal select2 library now uses only select input types, but it does work with input types when using select2-full library. So, this was a way out

Change id in simple form

喜欢而已 提交于 2019-11-30 21:28:44
问题 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: <form accept-charset="UTF-8" action="http://mikhail.smackaho.st:3000/account" class="edit_account" data-validate="true" id="edit_account_4f15c0a487f4463d8d000004" method="post" novalidate="novalidate"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"><input name="_method" type=