开发者

Default value not set in select

开发者 https://www.devze.com 2023-03-26 12:43 出处:网络
can anyone see why \"9:00\" isn\'t selected in this select? =f.fields_for :hours do |hours_form| = hours_form.text_field :start_time # outputs \"9:00\"

can anyone see why "9:00" isn't selected in this select?

=f.fields_for :hours do |hours_form|
  = hours_form.text_field :start_time # outputs "9:00"

  =hours_form.select :start_time, possible_hours_stop() # outputs a select including one where va开发者_StackOverflowlue="9:00"

Shouldn't "9:00" be selected since that's the value of :start_time?


I would try this:

=hours_form.select :start_time, options_for_select(possible_hours_stop(), hours_form.object.start_time)
0

精彩评论

暂无评论...
验证码 换一张
取 消