加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 选择元素,simple_form帮助器

发布时间:2020-12-17 03:39:05 所属栏目:百科 来源:网络整理
导读:我试图在我的表单中创建一个使用简单表单引导程序的元素.这个想法是允许用户从下拉列表中选择一种货币. Customer_currency可选择美元 – 美元,LRD – 利比里亚元等. 我在表单中使用了以下内容 但是,它不起作用,我看到的只是在我的表单中有一个选项但没有标签
我试图在我的表单中创建一个使用简单表单引导程序的元素.这个想法是允许用户从下拉列表中选择一种货币.

Customer_currency可选择美元 – 美元,LRD – 利比里亚元等.

我在表单中使用了以下内容

但是,它不起作用,我看到的只是在我的表单中有一个选项但没有标签的下拉(不在位置).

如何使用简单的表单创建带有标签的良好选择元素

<%= simple_form_for @customer,:html => { :class => 'form-horizontal' } do |f| %>
<%= f.input :name %>
<%= f.select :customer_currency,[['UGX- Uganda Shillings',1],['USD- US Dollars',2]] %>
<%= f.input :payment_terms %>
<%= f.input :billing_address %>
<%= f.input :first_name %>
<%= f.input :last_name %>
<%= f.input :mobile %>
<%= f.input :email %>
<div class="form-actions">
<%= f.button :submit,:class => 'btn-primary' %>
<%= link_to t('.cancel',:default => t("helpers.links.cancel")),customers_path,:class => 'btn' %>
</div>
<% end %>

解决方法

<%= f.input :customer_currency,:collection => [['UGX- Uganda Shillings',2]] %>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读