Почему элементы выпадающего списка не отображаются в моем коде коллекции simple_form_for при отображении страницы? - PullRequest
0 голосов
/ 05 ноября 2019

Я пытаюсь вставить раскрывающийся список simple_form на мою страницу, но у меня возникают проблемы с отображением элементов списка (два адреса электронной почты - conatct@test.com и support@test.com). Когда я нажимаю стрелку раскрывающегося списка, они просто не отображаются, поскольку их там не было.

.reveal.doubt id="doubt-material-#{material.id}" data-reveal=true
  button.close-button data-close=true aria-label="Close reveal" type="button"
    span aria-hidden="true" ×
  h5 #{t 'students.materials.index.questions.button'}
  p #{t 'students.materials.index.questions.form_explanation'}
  = simple_form_for [:student, trail, component, material, material_student, doubt], html: { id: "doubt" }, remote: true do |f|
    = f.input :recipient, collection => %w(contact@test.com, support@test.com), label: "#{t 'students.materials.index.questions.form_send_email'}"
    = f.input :question, as: :text, label: true, label: "#{t 'students.materials.index.questions.form_message'}" , input_html: { rows: "2" }
    = f.submit "#{t 'students.materials.index.questions.form_send_button'}", class: 'button primary-button-active'

Когда я проверяю код, кажется, что он работает, но я нигде не вижу параметров электронной почты.

Добавленная строка кода:

= f.input :recipient, collection: %w(contact@test.com, support@test.com), label: "#{t 'students.materials.index.questions.form_send_email'}"

Что здесь не так?

1 Ответ

0 голосов
/ 05 ноября 2019

Я полагаю, что для вашей коллекции необходимо установить name и value для каждой опции. Вы можете попробовать: [["contact@test.com", "contact@test.com"], ["support@test.com", "support@test.com"]]. Или используйте вспомогательный метод Rails options_for_select :

= f.input :recipient, collection => options_for_select(%w[contact@test.com contact@test.com])
...