0

Active Admin では、ドロップダウン フィールドのセットではなく、適切な Datepicker をレンダリングする次のことができます。

f.input :some_date, :as => :datepicker

ここに画像の説明を入力

ただし、カスタム フォームでこれを行うと、次のエラーが発生します。

No input found for datepicker

ただし、これは Active-Admin 以外では機能しません。simple_form ベースのフォームで同じことを行う簡単な方法はありますか?

4

1 に答える 1

0

あなたは単純なフォームで私がすることをすることができます:(今日のボタン= Pとして設定されています)

日付ピッカー フィールドの JavaScript を追加します...

// my_javascript.js
$('#position_buy_date').datepicker({
    showOtherMonths: true,
    dateFormat: 'yy-mm-dd'
});
$('#set_buy_date').on('click', function (){
    $('#position_buy_date').datepicker('setDate', new Date());
});

入力フィールドを文字列に変更します

<%= f.input :buy_date, as: :string, hint: button_tag('Set as today', type: 'button', class: 'btn', id: 'set_buy_date') %>

于 2013-04-20T16:08:31.603 に答える