We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

NEW - Custom Drop Down Creator…

Development and Programming

Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

Hiya,

Here’s another one for anyone that might be interested. This allows you to re-create a drop-down menu in a form if you have a custom field of type drop-down.

Instructions are fairly simple :

Version 1.0.1 - Added initial_value_value and initial_value_option parameters

<select id="{exp:custom_drop_down:field_id field_name="drop-down"}" name="{exp:custom_drop_down:field_id field_name="drop-down"}">

{exp:custom_drop_down field_name="drop-down" initial_value_value="my-value" initial_value_option="Choose an option…"}
<option value="{value}">{value}</option>
{/exp:custom_drop_down}

</select>

If you leave the initial_value_option=”” parameter blank then nothing will be output and you will just get your options without an initial one.

Version 1.0

<select id="{exp:custom_drop_down:field_id field_name="field_name_goes_here"}" name="{exp:custom_drop_down:field_id field_name="field_name_goes_here"}">

{exp:custom_drop_down field_name="field_name_goes_here"}
<option value="{value}">{value}</option>
{/exp:custom_drop_down}
</select>

Hope it helps.

Best wishes,

Mark

Disclaimer I’m pretty sure this should just work as advertised but please don’t sue me if anything goes wrong 😉
       
Glenabbey's avatar
Glenabbey
9 posts
16 years ago
Glenabbey's avatar Glenabbey

thanks Mark - another doozazzling plugin - might come in handy if I ever figure out how to extend search so that you can pass through a value (eg. song_key) via a dropdown and that the field (eg. song_key) is searched for that value (as well as the usual keywords)

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Hi Glen,

Wow my first person who has seen this one!! 😉

Didn’t think anyone would ever find it although looking at the file above seems it has been downloaded quite a lot! Weird! There must be a lot of silent users in here!! 😉

Best wishes,

Mark

       
lukemcr's avatar
lukemcr
154 posts
16 years ago
lukemcr's avatar lukemcr

I’m using this too - it’s really useful, actually. Thank you Mark.

One weird thing that I’ve noticed, though: the dropdown on the front-end side has a blank line between every option value. Those HTML it produces looks like this:

<option value="---">---<option>

<option value="Child Care">Child Care<option>

<option value="Childs Play Center">Childs Play Center<option>

<option value="Day Care & After Sch">Day Care & After Sch<option>

<option value="Day Nsy/Kindergarten">Day Nsy/Kindergarten<option>

<option value="Day Nursery Infants">Day Nursery Infants<option>

when it should, I think, look like this:

<option value="---">---<option>
<option value="Child Care">Child Care<option>
<option value="Childs Play Center">Childs Play Center<option>
<option value="Day Care & After Sch">Day Care & After Sch<option>
<option value="Day Nsy/Kindergarten">Day Nsy/Kindergarten<option>
<option value="Day Nursery Infants">Day Nursery Infants<option>

Those extra lines are showing up on the frontend. Has anyone else had this problem? Have you worked around this, Mark?

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Hi Luke,

Thanks for the comment on the plugin.

Have you tried this at all?

<select id="{exp:custom_drop_down:field_id field_name="drop-down"}" name="{exp:custom_drop_down:field_id field_name="drop-down"}">
{exp:custom_drop_down field_name="drop-down"}<option value="{value}">{value}</option>
{/exp:custom_drop_down}</select>

That should hopefully fix it up for you?

Best wishes,

Mark

       
Jamosdesign's avatar
Jamosdesign
4 posts
16 years ago
Jamosdesign's avatar Jamosdesign

I’m having some problems when setting the “initial_value_option”. I use this plugin in combination with the form helper to create a stand alone edit form were customers can edit their previously entered data.

When I use the following code to display the current value for my field “ploeg”, the correct value is displayed in my page : {exp:form_helper:field_parser}{ploeg}{/exp:form_helper:field_parser}

Now, when I use the same code to fill in the “inital_value_option” field, the resulting drop down field contains some gibberish value.

<select id=”{exp:custom_drop_down:field_id field_name="ploeg"}” name=”{exp:custom_drop_down:field_id field_name="ploeg"}”>

{exp:custom_drop_down field_name="ploeg" initial_value_option="{exp:form_helper:field_parser}{ploeg}{/exp:form_helper:field_parser}”} <option value=”{value}”>{value}</option> {/exp:custom_drop_down} </select>

Is this is a bug or am I using this option in the wrong way ?

       
Jim Pannell's avatar
Jim Pannell
187 posts
16 years ago
Jim Pannell's avatar Jim Pannell

Hi Mark

Does your plugin support output where more than one option is selected at a time? Like this:

<select id="field_id_18" name="field_id_18[]" multiple="true" size="6">
<option value='Please select...'>Please select...</option>
<option value='Teachers' selected='selected'>Teachers</option>
<option value='Environmental educators' selected='selected'>Environmental educators</option>
<option value='Play/youth leaders'>Play/youth leaders</option>
<option value='Early years providers (4 years and under)'>Early years providers (4 years and under)</option>
<option value='Young People'>Young People</option>
<option value='Anyone'>Anyone</option>
</select>

I’m looking for a way of showing multiple selections in a select field for a SAEF. Any suggestions?

cheers

Jim

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Hi Jim,

If you mean to have the selections already made when outputting the list then no it doesn’t do that and I don’t actually see an easy way of doing that really as all that gets stored in a drop-down list custom field is the names of each option and not whether or not they are selected or not.

Really all my plugin does is finds the options and then spits each one out. To be able to make more than one selected automatically would mean it would need more information that unfortunately isn’t available to it.

Best wishes,

Mark

       
Jim Pannell's avatar
Jim Pannell
187 posts
16 years ago
Jim Pannell's avatar Jim Pannell

Thanks for your quick reply. No worries about your plugin not being able to do that. I’m sure I’ll find a use for it somewhere else 😊.

I guess my search will continue…

Jim

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen
I guess my search will continue… Jim

Sorry about that :down:

Hope you find something that works for you.

Best wishes,

Mark

       
journalistone's avatar
journalistone
78 posts
16 years ago
journalistone's avatar journalistone

Hello Mark et al.

I am just trying to create a Drop Down List in my user registration form populated from one of my custom profile fields. I am using a SAEF for member registration.

I have used your plugin and code: but my Drop Down list is showing nothing, not even the initial value ???

My code is here below. Is there something I am missing? My only guess is that it has something to do with being the Member Register form, or should that not mean anything ?? What I also need to ensure is that the selected value is then fed back to the database.

<select id="{exp:custom_drop_down:field_id field_name="position"}" name="{exp:custom_drop_down:field_id field_name="position"}" >
{exp:custom_drop_down field_name="position" initial_value_value="Undergraduate" initial_value_option="Choose an option…"}
<option value="{value}">{value}</option>
{/exp:custom_drop_down}
</select>

<label for="position">Your Position</label>

Mark: I had a look in the php file and I noticed that the plugin makes the call from : exp_weblog_fields

Does this mean that it is because I am trying to get this to work in the Member Profile ?

If so, is there another nice plugin solution here ??? 😉

Thank you any urgent assistance here 😊

Alison

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Hi Alison,

Unfortunately the plugin was created for use with custom weblog fields only and not member profile fields. I’m not entirely certain that a plugin would work in your instance anyway as I don’t believe that the registration form will allow for plugins to be run inside of it. I might be wrong on that one but I know that those templates don’t allow as much to go on as normal weblog templates and so this is why I’ve never really looked at making anything for them I’m afraid.

Someone else might have an idea though hopefully.

Best wishes,

Mark

       
journalistone's avatar
journalistone
78 posts
16 years ago
journalistone's avatar journalistone

Gosh that was quick ! It is good to know at least that I can stop heading down this direction 😊 I will use your plugin in other ways though … so that is great.

While I am here, do you know how a member Profile drop down list natively works as a drop down list from the custom profile fields ? I am finding my self populating, by hand, both the custom profile field in EE member temlate and then again in the actual SAEF registration form.???

Thanks Mark.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Hiya,

While I am here, do you know how a member Profile drop down list natively works as a drop down list from the custom profile fields?

That will be some of the core ExpressionEngine code that creates those drop-downs so not too sure where it lives but would definitely be in one of the core files possibly something like the system->modules->member->mod.member.php file or somewhere like that I would imagine.

I am finding my self populating, by hand, both the custom profile field in EE member temlate and then again in the actual SAEF registration form.??? Thanks Mark.

Not sure if it will work in the registration form or not but I have very very quickly modified the original plugin to create a new plugin which will only work with custom profile fields instead. Please note that it can only be used for Profile fields and not weblog fields as this was done very quickly.

Pretty much the same code as before but with a slight name change :

<select id="{exp:custom_drop_down_profile:field_id field_name="profile-drop-down"}" name="{exp:custom_drop_down_profile:field_id field_name="profile-drop-down"}">

{exp:custom_drop_down_profile field_name="profile-drop-down" initial_value_value="my-value" initial_value_option="Choose an option…"}
<option value="{value}">{value}</option>
{/exp:custom_drop_down_profile}

</select>

Hope it helps a bit. As said before though I know this should work in normal templates that you create in the Templates area but as to using this plugin in the registration templates I’m not so sure of.

Best wishes,

Mark

       
journalistone's avatar
journalistone
78 posts
16 years ago
journalistone's avatar journalistone

Hi Hi Hi !!!

I won’t get too excited, and say things like ‘I could kiss you’ - but I just quickly installed the new plugin, and relevant code into the SAEF Registration form… and whamo, It Worked !!!! I submitted a new test registration form and everything went smoothly, right through to the database !!!

THANK YOU MARK …

       
1 2

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.