0
하나의 선택 사항을 다른 형식으로 표시 할 수 있도록하기위한 형식이 필요합니다.중첩 된 형식의 동적 선택자
나는 다음과 같은 DB 스키마 한 : 나는 다음과 같은 형태로 한
order <-->> line_items <<-->> product <-->> campaign <br>
order <<--> customer
:에 나는 필터 제품 선택이 제품을 보여줄 수있는 캠페인 선택기를 보여주기 위해 여기
form do |f|
f.inputs I18n.t("New Order") do
f.input :customer, :collection => Customer.where(:id => order.customer_id).map{ |customer| [customer. FirstName + ' ' + customer.LastName, customer.id] }
end
f.has_many :line_items do |app_f|
app_f.input :quantity
#some code that show campaign to filter :product_id
app_f.input :product_id, :as => :select, :collection => Product.all.map{ |product| [product.name, product.id] }
if app_f.object.id
app_f.input :_destroy, :as => :boolean, :label => I18n.t("Delete")
end
app_f.form_buffers.last # to avoid bug with nil possibly being returned from the above
end
end
f.actions
end
필요를 기반으로 자신의 중첩 된 형태의 캠페인 (제품 카테고리 필터가있는 것과 유사)
어떻게 할 수 있습니까?
감사합니다,
양식 복잡성의 수준에 도달하면
감사합니다 @SimonHildebrandt는 Formtastic 한도에 도달했습니다. 부분적으로 완전히 양식을 다시 작성하고 이전과 같이 작동하게하십시오. 그러나 js 부분으로 힘든 시간을 보내고 있습니다. 저를 올바른 길로 인도 할 수있는 힌트 나 코드가 있습니까? –