ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Create list of multiselect field

March 06, 2011 3:24pm

Subscribe [3]
  • #1 / Mar 06, 2011 3:24pm

    webnology

    353 posts

    Hi all,

    does someone have the code to create a drop down list in the front end, from all the possible entries in the back end?

    I have a list of a lot of countries in the backend, in one of the custom fields. For a search function, I need to show all those entries in a drop down list.

    ALl help appreciated,
    M

    Moved to CodeShare Corner by Moderator

  • #2 / Mar 06, 2011 4:02pm

    Mark Bowen

    12637 posts

    When you say you have a list of Countries in the backend in a custom field I’m guessing that you mean a select drop down?

    If so then I have an add-on on devot-ee.com which allows you to do this.

    Custom Drop Down Creator

    Don’t know if that’s any use to you?

    Best wishes,

    Mark

  • #3 / Mar 07, 2011 3:03am

    webnology

    353 posts

    Mark, thx. Will it also work if my custom field is a multislect field?

  • #4 / Mar 07, 2011 4:12am

    Mark Bowen

    12637 posts

    Mark, thx. Will it also work if my custom field is a multislect field?

    To tell the truth I’m silly and had never tried it with one of those!!

    Just tried it out though and it works fine. I will update the documentation over on devot:ee to show how it needs to go in order for this to work.

    Best wishes,

    Mark

  • #5 / Mar 07, 2011 4:19am

    webnology

    353 posts

    Thx. Sold 😉

  • #6 / Mar 07, 2011 4:19am

    Mark Bowen

    12637 posts

    Okay I’m going to be totally honest here and say that although the Safecracker documentation doesn’t show how to do this you can indeed do this for free with Safecracker by just adding in those bits of code that I added into my add-on.

    Didn’t want anyone to think I was just trying to make a quick buck that’s all.

    Best wishes,

    Mark

  • #7 / Mar 07, 2011 4:22am

    Mark Bowen

    12637 posts

    Thx. Sold 😉

    If you’ve already purchased this then please do feel free to ask for a refund from devot:ee as I wasn’t aware that Safecracker already did this. I had written this add-on way before Safecracker ever came about so didn’t know about it.

    Best wishes,

    Mark

  • #8 / Mar 07, 2011 4:28am

    webnology

    353 posts

    oh, taht’s good. And honest! Thx for that. DIdn’ tbuy it yet, by the way. Thx for the help and pointing me to Safecracker.

  • #9 / Mar 07, 2011 4:32am

    Mark Bowen

    12637 posts

    oh, taht’s good. And honest! Thx for that. DIdn’ tbuy it yet, by the way. Thx for the help and pointing me to Safecracker.

    No problem. Once again, sorry about that as I had created my add-on way before Safecracker ever came about so I wasn’t aware of that.

    Just as a note though my add-on will still be useful to people who want to use it outside of Safecracker for anything else they might need as the Safecracker code won’t work outside of the Safecracker tags.

    Best wishes,

    Mark

  • #10 / Mar 07, 2011 4:35am

    webnology

    353 posts

    Well, I just need it to quickly generate a drop down list. I pass on the variables of that form to search via dynamic parameters. So, I’ll need your code I guess?

  • #11 / Mar 07, 2011 5:10am

    Mark Bowen

    12637 posts

    Well, I just need it to quickly generate a drop down list. I pass on the variables of that form to search via dynamic parameters. So, I’ll need your code I guess?

    You know what I think I must have been asleep whilst posting what I did above as I’m wondering why I ever mentioned Safecracker in the first place as you have mentioned a search form. I must have been responding to someone else as I know someone was asking about a stand alone entry form somewhere.

    Must have got my posts crossed somewhere 😉

    In that case, yes you would need something like my plugin in order to achieve what you need after all. It will definitely spit out the items and you will be able to select as normal but I’m not totally sure how it will work in conjunction with whatever you’re using for your search function. That would have to be something you’d need to test yourself I guess though.

    Best wishes,

    Mark

  • #12 / Mar 07, 2011 6:39am

    webnology

    353 posts

    Hey MArk,

    I’ve installed the plugin, but can’t make it work it work yet.

    Just to be clear:
    -I have a custom field ‘countries’ which is a multiselect filed in the backend
    -I need a dropdown menu of all the countries, based on the entries in the backend. This field in the front end is simply a drop down, no multiselect

    This is the codeI’ve put in:

    <select id="{exp:custom_drop_down:field_id field_name="search:countries"}" name="{exp:custom_drop_down:field_id field_name="search:countries"}">
    {exp:custom_drop_down field_name="landen" separate_values="yes" initial_value_value="" initial_value_option="Kies een land…"}
    <option value="{value}">{label}</option>
    {/exp:custom_drop_down}

    Any idea what might go wrong?

    Regards,
    Michel

  • #13 / Mar 07, 2011 7:18am

    Mark Bowen

    12637 posts

    This field in the front end is simply a drop down, no multiselect

    Just wondering why you’ve got it as a multi select in the admin panel but not in the front end? No worries as I’m fairly certain it should work anyway but just wondering?

    This is the codeI’ve put in:

    <select id="{exp:custom_drop_down:field_id field_name="search:countries"}" name="{exp:custom_drop_down:field_id field_name="search:countries"}">
    {exp:custom_drop_down field_name="landen" separate_values="yes" initial_value_value="" initial_value_option="Kies een land…"}
    <option value="{value}">{label}</option>
    {/exp:custom_drop_down}

    Any idea what might go wrong?

    Not too sure where you got {label} from but try this instead :

    <select multiple="multiple" id="{exp:custom_drop_down:field_id field_name="countries"}" name="{exp:custom_drop_down:field_id field_name="countries"}[]">
        {exp:custom_drop_down field_name="countries" initial_value_value="my-value" initial_value_option="Kies een land……"}
        <option value="{value}">{value}</option>
        {/exp:custom_drop_down}
        </select>

    The search:countries part is what was probably messing this up. As mentioned this add-on is just for creating the drop-down menu or multi select menu. Getting it to work within a search application would have to be up to the end user.

    Also can I ask that you post any more support questions over at devot-ee.com as we’re not supposed to use the forums here for add-on support. Thanks.

    Best wishes,

    Mark

    P.S. Hope this gets you up and running and thanks for the purchase.

  • #14 / Mar 07, 2011 8:52am

    Mark Bowen

    12637 posts

    Hiya,

    Just wondering if that got it working for you or not?

    Best wishes,

    Mark

  • #15 / Mar 07, 2011 9:09am

    webnology

    353 posts

    Hi Mark,

    the {label} I got from the Devotee examples.

    The reason it is multiselect is because every partner can travel to lots of countries, but the visiotr searches for a specific partner based on the country he wishes to go to.

    The list is displaying fine. It gives the column id though, so I’ll need to switch that somehow to the label, so I can pass it on to the dynamic_parameters.

    Thx for the help,
    Michel

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases