simple_form gemを使用しており、「created_at」フィールドのタイプをinputからtext_fieldに変更する必要があります(このフィールドをjQueryの日付ピッカーで使用するため)。出来ますか?
as: :string
jQuery.datepickerで動作しないため、適切な回答ではありません
simple_form gemを使用しており、「created_at」フィールドのタイプをinputからtext_fieldに変更する必要があります(このフィールドをjQueryの日付ピッカーで使用するため)。出来ますか?
as: :string
jQuery.datepickerで動作しないため、適切な回答ではありません
app / input/date_picker.rbに特定のDatePickerInputクラスを作成する必要があります
app/inputs/date_picker.rb
class DatePickerInput < SimpleForm::Inputs::StringInput
def input
value = object.send(attribute_name) if object.respond_to? attribute_name
input_html_options[:value] ||= I18n.localize(value) if value.present?
input_html_classes << "datepicker"
super # leave StringInput do the real rendering
end
end
javascript
jQuery ->
$('input.date_picker').datepicker()
フォームに次の行を追加するだけです
= f.input :due, as: :date_picker
このスレッドは私の問題を解決しましたrioのおかげでSimpleFormのよりクリーンな日付ピッカー入力を書くにはどうすればよいですか