2012-11-13 2 views
4

간단한 폼 + 부트 스트랩을 사용하는 폼에서 요소를 만들려고합니다. 아이디어는 사용자가 드롭 다운에서 통화 유형을 선택할 수 있도록하는 것입니다.요소, simple_form 도우미

Customer_currency는 미국 달러, LRD - 라이베리아 달러 중에서 선택할 수 있습니다.

나는 내가 보는 모든 옵션이 있지만 레이블 내 형태 (위치 만점) 드롭 다운, 그것은 작동하지 않습니다,

그러나 내 양식에 다음을 사용했다.

어떻게 의미, 당신의 선택에 label_methodvalue_method 추가 간단한 형태

<%= 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 %> 
+0

유무는 내가 그것을 게시, 내 대답을 시도 – zurik

+0

질문에 추가. – Thanh

+0

어떤 이유로 든 여전히 새로운 레이블 – zurik

답변

0

를 사용하여 레이블이 좋은 선택 요소를 만들 수 있습니다 변화 :

<%= f.select :customer_currency, [['UGX- Uganda Shillings',1],['USD- US Dollars',2]] %> 

에 :

<%= f.select :customer_currency, [['UGX- Uganda Shillings',1],['USD- US Dollars',2]], label_method: :first, value_method: :last %> 

업데이트 : 다른 해결책

<%= f.input :customer_currency, as: :select, [['UGX- Uganda Shillings',1],['USD- US Dollars',2]], label_method: :first, value_method: :last %> 
+0

업데이트가 작동하지 않았지만이 중 하나가 <% = f.input : customer_currency, : collection => [[ 'UGX- 우간다 실링, 1], ['USD- 미국 달러 ', 2]] %> – zurik

+0

@ zurik 알겠습니다. 답을 게시하고 수락하십시오. – Thanh

8
<%= f.input :customer_currency, :collection => [['UGX- Uganda Shillings',1],['USD- US Dollars',2]] %> 
+1

이것은 간단한 양식에서 올바른 방법입니다. –