All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Searching multiple custom fields

Russ Back 12 Aug 2013 19:44 question, complete

Hey Low

Apologies if I'm missing something (and I'm sure I am!), I need to search for 'foo' in in one of two custom fields. I'm confused about whether I should be defining something on the form or on the text field where the user enters 'foo'.

Could you point me in the right direction please?

Thanks

Replies

  1. Low 12 Aug 2013 20:29

    If you want to target a specific custom field, you'd use the native search: parameter. You can use it as an input field as well:

    <input name="search:field_name" value="foo" />

  2. Russ Back 12 Aug 2013 20:49

    Thanks, I can't see how you would search multiple fields doing that though? This works:

    <input type="text" id="inp-consultants-name" name="search:member_firstname" placeholder="Search by Name">


    But this:

    <input type="text" id="inp-consultants-name" name="search:member_firstname|member_lastname" placeholder="Search by Name">


    Displays an 'Disallowed Key Characters.' message.

  3. Low 12 Aug 2013 20:54

    Think of it as you would with the native channel:entries parameters. You can target 2 fields like this:

    search:field1="foo" search:field2="foo"


    This translates to field1 contains "foo" and field2 contains "foo". As input fields, you'd use:

    <input name="search:field1" value="foo"> 
    <input name="search:field2" value="foo">


    However, you can't search for field1=foo or field2=foo at the moment.

  4. Russ Back 13 Aug 2013 09:03

    Thanks Low.