0

I have two Model Product and Supplier.

Product has_one supplier.

how to Build a Seach form inside a form. ,I want to Search Supplier and Put that id into My Product form.

Currently my code look like this.

<%= f.text_field :product_code, class: 'form-control'%>

<%= f.text_field :product_name, class: 'form-control'%>

<%= f.text_field :supplier_id, class: 'form-control'%>

<%= render :partial => 'supplier_search' %>

<%= f.submit 'Save', :class=>'button add'%>
Siva KB
  • 357
  • 1
  • 6
  • 19

2 Answers2

1

Render suplier_search partial after submit button of product form.

<%= f.text_field :code, class: 'form-control'%>

<%= f.text_field :supplier_id, class: 'form-control'%>

<%= f.submit 'Save', :class=>'button add'%>

<%= render :partial => 'supplier_search' %>

Or

Don't have form in suplier_search partial. Just put input field or whatever you want, there and submit those fields via Ajax and get your required results in product form.

Ramiz Raja
  • 5,942
  • 3
  • 27
  • 39
-1

if its not partialing for <%= render :partial => 'supplier_search' %> then use

"your views folder name/supplier_search" %>
Sanket
  • 165
  • 6
  • the partial view is working but when i submit the form in partial file is goes to product create instead of supplier search . – Siva KB Feb 10 '14 at 07:12