gpt4 book ai didi

ruby-on-rails - 选择元素,simple_form 助手

转载 作者:行者123 更新时间:2023-12-04 06:29:58 25 4
gpt4 key购买 nike

我正在尝试在我的表单中创建一个使用简单表单 + bootstrap 的元素。这个想法是允许用户从下拉列表中选择一种货币。

Customer_currency 可选择 USD- 美元、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',1],['USD- US Dollars',2]] %>

关于ruby-on-rails - 选择元素,simple_form 助手,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13357356/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com