Man*_*ava 2 ruby html-helper ruby-on-rails ruby-on-rails-3
在我的注册中,我有Choose a Question
下拉列表:下面的代码
<%= f.select("question_id", Question.all.collect {|p| [ p.body, p.id ] }])) %>
Run Code Online (Sandbox Code Playgroud)
我想得到如下的输出
<select name="question" id="login_fields_question" class="signup_fields" >
<option value="choosequestion" selected="selected" style="font-style:italic;">Choose a question ...</option>
<option value="1"> What is your pet name?</option>
<option value="2">What is the name of your best friend from childhood?</option>
<option value="3">What was the name of your first teacher?</option>
<option value="4">What is the name of your manager at your first job?</option>
<option value="5">What was your first phone number?</option>
<option value="6">What is your vehicle registration number?</option>
Run Code Online (Sandbox Code Playgroud)
使用代码f.select
我可以从数据库中获取所有问题但是如何Choose a question ...
在我的下拉列表中添加选项?它将在默认情况下显示,并可以按上述HTML代码提供输出
归档时间: |
|
查看次数: |
439 次 |
最近记录: |