1. Fabrik 3.8 has been released. As usual, we strongly recommend that you backup your site (using Akeeba) before upgrading. Report any issues in the forums, we will answer promptly.

How do I use a form to filter / search a table?

Discussion in 'Frequently Answered Questions' started by cheesegrits, Dec 22, 2007.

  1. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    A common requirement in Fabrik apps is to create a form which acts as a search filter for a table.

    Lets say you have a table of Widgets, which have a 'description' and a 'name' element. You want to set up a form which will search the table on those two elements.

    Create a new group (widget_search).

    Create two elements in that group which have the same names as the elements in Widgets you are searching on ('name' and 'description'). Usually the easiest way to do this is to copy the original element, edit it, change the name back to the original name (it will have called itself copy_of_foo), and change the group to your new search group.

    Create a new form (Widget Search). Include the new widget_search group. Don't enable email receipts, do not record in database. Set the Jump Page to the URL of the Widget table page (if in doubt just copy and paste it from your browser). Link the the form to your desired menu.

    And that's it. When the Widget Search form is submitted, it will jump to the Widget Table page, and filter the table according to the values on the Widget Search form.

    NOTE - your Widget Table page should probably not have any search features (element filters, advanced search) enabled, as these will tend to override what you are sending it from the search form.

    -- hugh
  2. shazan

    shazan New Member

    Level: Community
    On a related issue, can we make the elements of a search form be the dropdown choices of all the types entered in the table to be searched through?, like the way a filter behaves? That much less work for the searcher?
  3. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Not sure what you mean.

    -- hugh
  4. belicino

    belicino New Member

    Level: Community
    It would be great if i could make an advanced filtering trough the form. For example selecting all records that have a a certain value range for a specific field (i.e. price < 100). Is there the possibility to make a query of this type by this method?
  5. vaulot

    vaulot New Member

    Level: Standard
    Filtering of forms...

    I think the solution outilined is very very clumsy... I just spent the whole afternoon battling with it. The first 50 elements are filtered but as soon as you go to next, no more filters....

    It would be great to be able to apply permanent filters to a table so that the user only sees a part of it. I could have then two menu items one with the filter and one without the filter...

    As it stands now each time you want to filter a table you have to make a copy of it with all the elements being duplicated... a real mess...
  6. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    We are working on improving some of this stuff in 2.0.

    Fabrik isn't a universal, do everything exactly how you want it solution. My usual analogy is that it's a Swiss Army Knife. As such, it does a lot of things pretty damn well, but has limitations. In this case, the little tweezer tool need some redesign. :)

    BTW, can you report that '50 elements and no more filters' as a bug in the appropriate forum?

    -- hugh
  7. vaulot

    vaulot New Member

    Level: Standard
    Yes indeed... the swiss knife analogy is appropriate (and sometimes you cut your fingers). At present there is nothing beating Fabrik...

    Still think that basic database operations like record navigation and easy filtering of table should be high on the list. I wil report the bug...
  8. vaulot

    vaulot New Member

    Level: Standard
    Filtering of tables


    I found a workaround which is... using DBQ

    Here is an example of the combination :

    Fabrik to use the nice filters ...

    And when I want to show specific view of my tables use DBQ :

    In fact using DBQ, I am able to point towards the forms designed under fabriks (click on link in first column) ...
  9. slboone

    slboone Member

    Level: Professional
    Is this the same procedure you would use in version 2? I do not see the Jump Page field that is referenced.
  10. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Check the 'redirect' form plugin.

    -- hugh
  11. railer

    railer Member

    Level: Professional
    Redirect condition code help


    What code would I put into the Redirect form plugin's condition that would check if the value entered into a single field exists in the table, and if so, process the redirect? Please furnish the full code to paste into the field, as that is where I'm stuck.

    Here is what I currently have:

    Code (Text):
    return '{fabrik_vendorlist___vendor_code}' = 1
    That's everything, but I must be missing something because even with a value entered that definitely exists in the database, it just hangs.


Share This Page