You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry if similar issue already exists, but I couldn't find anything on the matter.
I have a model (let's say Product) that belongs_to another model - Category. I need to implement search on products by two fields: product.name and category.name (using assoc: ['category']). Both fields have the same name - name.
This code (surprisingly) works:
<%=search_form(@conn,@rummage,[fields:[name: %{label: "Search by category name",search_type: "ilike",assoc: ["category"]},name: %{label: "Search by name",search_type: "ilike"}],button_class: "btn",])%>
But if I change the order of fields, it only filters by the association name.
<%=search_form(@conn,@rummage,[fields:[name: %{label: "Search by name",search_type: "ilike"},name: %{label: "Search by category name",search_type: "ilike",assoc: ["category"]}],button_class: "btn",])%>
If I skip the search_form and implement the same form using form_for and inputs_for, this inconsistency persists.
I realize that this case should probably be handled differently, but I can't find any documentation or example of the correct way of doing it, so any help is appreciated.
The text was updated successfully, but these errors were encountered:
Hey @0190, This is a genuine bug, with frankly only one type of solution, which is creating two separate forms. rummage_ecto2.0 is coming with features like rummage_scope which will make defining these fields easier. But even with that, you will need two forms. Unfortunately, I don't see a cleaner way of doing this.
Hi there!
Sorry if similar issue already exists, but I couldn't find anything on the matter.
I have a model (let's say
Product
) thatbelongs_to
another model -Category
. I need to implement search onproducts
by two fields:product.name
andcategory.name
(usingassoc: ['category']
). Both fields have the same name -name
.This code (surprisingly) works:
But if I change the order of
fields
, it only filters by the association name.If I skip the
search_form
and implement the same form usingform_for
andinputs_for
, this inconsistency persists.I realize that this case should probably be handled differently, but I can't find any documentation or example of the correct way of doing it, so any help is appreciated.
The text was updated successfully, but these errors were encountered: