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

Support archive

Combining multiple custom fields into a single dropdown

Stephen 28 Jun 2012 04:20 question, complete

Hi Low,

Is it possible to have a single dropdown field that would contain multiple custom fields so that the user can choose which one of these they wish to filter their results by?

I'm wanting to allow users to search events by day. I've already got this working well on my 'advanced search' form as a single checkbox field for each day, but on the short/simple form, space is limited so I wondered if I could combine multiple fields into a single dropdown.

I've tried the code below but not surprisingly, it didn't work. Just wondered if what I'm trying to do is possible or not?


<label for="day">Choose a day</label>
<select name="day">
<option value="">All days</option>
<option value="search:cf_directory_opening_times_thu='not IS_EMPTY'">Thursday</option>
<option value="search:cf_directory_opening_times_fri='not IS_EMPTY'">Friday</option>
<option value="search:cf_directory_opening_times_sat='not IS_EMPTY'">Saturday</option>
<option value="search:cf_directory_opening_times_sun='not IS_EMPTY'">Sunday</option>
</select>


Thanks,

Stephen

Replies

  1. Low 28 Jun 2012 06:48

    No, I'm afraid that won't work. If the fields are multiple custom fields in your channel, then you need multiple input fields to populate them, using the name="" attribute per input element to point to each field.

  2. Stephen 28 Jun 2012 11:40

    Hi Low,

    I'm not surprised this isn't possible, but thanks for confirming. :)

    Thanks,

    Stephen

  3. Stephen 26 Feb 2013 16:07

    Hi Low,

    8 months on, and I've got a similar request as I work on more changes to this form.

    I'm guessing it's still not possible, but I'm trying to do this - have one field to do an OR search in three custom fields (but using a text field this time):

     
    <input type="text" name="search:cf_organiser_address_1|cf_organiser_address_2|cf_organiser_address_3" placeholder="Address" value="" />


    The above gives an error due to the name, but you can see what I'm trying to do - is this possible via another method at all?

    I guess the workaround is to make sure the fields are searchable and tell the user to use the keywords field.

    Thanks,

    Stephen

  4. Stephen 27 Jun 2013 10:02

    Hi Low,

    Further to my last question above from 4 months ago, is it possible to do this with an AND search, even?

    Got a client asking if it's possible to search for a specific value in 4 different custom fields by using one field or checkbox (so saving time on selecting the value in the 4 different fields, as it's something they're doing regularly).

    I know you said I'd need 4 input fields 12 months ago, but that was 12 months ago and things change! So that's why I'm asking again. :-)

    I do have a workaround in mind for this though - using a checkbox and some JavaScript, to make these 4 values in the 4 different fields have a selected state.

    Thanks,

    Stephen

  5. Low 27 Jun 2013 19:34

    Having a pipe-separated name targeting multiple filters is currently not possible. Best go for your workaround for now.

  6. Stephen 27 Jun 2013 21:17

    Okay, thanks for confirming, Low.