date_select having indentation issues in Ruby on Rails?

时间:2018-12-03 13:20:19

标签: ruby-on-rails datepicker

    <div class="row">
      <div class="col-sm-4">
        <%= label_tag 'Production_Month' %>
      </div>
      <div  class="col-lg-2">:</div>
      <div  class="col-lg-2"></div>
      <div  class="col-sm-4">
          <%= date_select(:params, :production_month, order: [:month, :year]) %>         
      </div>
    </div>

I am using the above date_select in one of my forms.

I have 2 questions here:

  1. The indentation of the date select seems to be right justified as shown below. How do I change it to left justified?

date select indentation issue

  1. Currently the year dropdown seems to display a list of -5 to +5 years from current year. How do I change it to display the list of years available in a model (say MyYears instead)?

1 个答案:

答案 0 :(得分:0)

我认为以下容器弄得一团糟:

      <div  class="col-lg-2">:</div>
      <div  class="col-lg-2"></div>

通过这种方式,您可以显示特定范围内的年份:

<%= date_select(:params, :production_month, order: [:month, :year], start_year: 2010, end_year: 2020) %>