Adds a "Chosen" Selector with an enhanced UI and auto-suggest
Product Setup
This plugin adds 4 new form element types for you to choose in Participants Database when configuring your fields on the Manage Database Fields page.
- Chosen Dropdown – Single-select control with search and improved UI
- Chosen Multi Dropdown – Multiple-Select control with search and tag UI
- Chosen Dropdown/Other – Single Selector control with the ability to add a new item
- Chosen Multi Dropdown/Other – Multiple-Select control the allows new items to be added
How to Use the Plugin
Once the plugin is activated all you need to do is select one of the new form element types in your field definition. The user messaging and other UI features may be configured in the plugin settings, in the Participants Database admin menu cluster.
Populating the Dropdown from the Database
Here is a tutorial on how to populate the Chosen Dropdown with options from the database–or any other source: Pre-load a “Chosen” Dropdown with Options from the Database
Product Settings
Selection Prompt
Message shown in the control before a selection is made.
Multi-Selection Prompt
Message shown in a multi-select control before a selection is made.
No Results Message
Message shown when using the search field and no matching selections are found.
Add Other Value Text
When “other” values are allowed, the message that is shown if the user has typed in something that doesn’t match any of the selections, suggesting that they can save it.
Disable Search Threshold
The number of items needed in a dropdown in order for the search function to be active. This is to prevent the search control from appearing when there are only a few items to select from. Has no effect on “other” form elements because the search input is where the use may type in a new value.
F.A.Q.
How do I create groups of options?
This is done in the “values” field of the field definition. A group of options is called an “optgroup” and you can define optgroups with a title like this:
Activities::optgroup
So for example, here is a list of options that have been divided into two groups:
Activity::optgroup, Sports::sports, Outdoors::outdoors, Yoga::yoga, Hobbies::optgroup, Photography::photography, Art/Crafts::crafts, Music::music, Cuisine::cuisine
That will display in the Chosen Dropdown like this:
Can the Chosen Dropdown have an "other" option?
Yes, it’s very simple to set up. In the field definition, choose “Chosen Dropdown/Other” or “Chosen Multi Dropdown/Other” depending if you want them to choose only one or let them choose several options. That gives the user the ability to type their option in and select it. It looks like this:
When using a multiselect, I can't remove the last item, it keeps coming back.
With the Chosen Multiselect Dropdown, you must define a “none” option in order to be able to clear the value. You only need to do this is you need to give your users a way to clear out all the values in a multiselect.
We do this by adding a “null_select” to the list of options, like in this example:
null_select::None
That will provide a “None” option that saves an empty value, in other words, if the user selects only “None” in the selector, any value that was stored for the field will be blanked out. This is of course not true if they choose other selections along with the “None.”
The word “None” can be anything you want. The “null_select” part tells the plugin that the field is meant to have a blank value.
Hi Roland,
I’m also having issues with the last version of the chosen dropdown plugin. On page load (or even when loading a participant’s data on the admin side) I get an error and the loading stop. I had to deactivate the plugin for the moment.
Fatal error: Uncaught Error: Call to undefined method PDb_FormElement::null_select_key() in /wp-content/plugins/pdb-chosen-dropdown-element/pdbcdl/Chosen_Dropdown.php:81 Stack trace: #0 /wp-content/plugins/pdb-chosen-dropdown-element/pdbcdl/Chosen_Dropdown.php(97): pdbcdl\Chosen_Dropdown->__construct(‘tags’, ”, Array, Array, Array, Array) #1 /wp-content/plugins/pdb-chosen-dropdown-element/pdbcdl/Plugin.php(115): pdbcdl\Chosen_Dropdown::element_html(Object(PDb_FormElement), Array, Array) #2 /wp-includes/class-wp-hook.php(288): pdbcdl\Plugin->build_chosen_element(Object(PDb_FormElement)) #3 /wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(”, Array) #4 /wp-includes/plugin.php(465): WP_Hook->do_action(Array in /wp-content/plugins/pdb-chosen-dropdown-element/pdbcdl/Chosen_Dropdown.php on line 81
Hope it helps to solve the issue.
Best wishes and thanks for your work!
Marius
Thanks for letting me know! I’ve issued a fix with an update to the Chosen Dropdown add-on.
Hi, Roland. I’d had a previous install of Chosen Dropdown and wiped it out. On reinstall whenever I select a Chosen DD field and view either the entry page or the “add participant” section of the dashboard settings, all fields will load until the first CDD field. There are no console errors I can see. but I see this in the server logs: “…PHP Fatal error: Uncaught Error: Call to undefined method PDb_FormElement::null_select_key() in…”
Am I missing something?
The update fixed my issue. Thanks, Roland.
Hi Roland,
I’m having an issue with version 1.8.1 of this plugin. Any page using a chosen dropdown will not load while the plugin is enabled. The pages load fine with the plugin disabled or with version 1.5.6 of the plugin. Any idea what may be causing this?
Thanks!
Possibly a php version issue? Also possibly a javascript conflict. If the page won’t load at all (i.e., blank), it’s probably on the server, and we’d need to take a look at the php error log to know what is going on. php version must be 5.4 or later, I believe.
If it’s a partial load, it could be a javascript issue. In that case, we need to look at the browser console for any javascript errors.
Hi Roland,
Just purchased this add on but not working with [pdb_list search=true] search fields.
Can you please help me? Thanks!
The shortcode you want is: [pdb_list template=multisearch]
Take a look at the plugin setup instructions for all the details.
Purchased that add-on as well. but dropdown is not showing! https://1ce.org/1#Bydj8LTeN
Do you have that field configured to show a chosen dropdown? If the field uses a chosen dropdown, then that control will also be used in the search control as well.
Can this add-on be modified to show list items that have been selected by other users (as options not available)? I have a list of items for users to select. Once an item is selected, other users can see the option is already chosen by someone else, displayed as grayed-out or even removed from the list of options.
It is possible, you’ll need to write some custom code that changes the available options of your dropdown (or whatever type of selector you are using) based on what selections have already been made. There is an action for this purpose: pdb-form_element_build_{$form_element_type} that gives you the form element object. You can alter the options property to dynamically set up the available options.
Hi again Roland,
Afraid the latest update hasn’t solved the autofilling field issue, nor has clearing the default for the field.
That means I don’t know what the issue is in your case. You can force a “null select” option by adding this as the first value of your defined values for the dropdown:
that will create the blank option that will default to selected.
Hi Roland,
That works, thanks; a blank entry still appears in the field, but this is better than having a meaningful one that might get left in by the user creating or editing the entry.
Cheers
Glad to hear it. If you aren’t using a default value, then a blank value is what you want.
You can also label the blank field if you want with something like this:
it won’t save anything and it won’t validate so if the field is required, they have to make a selection.
Hi Roland, this both looks and works very well for us, so thanks! I just have one glitch. On both the [pdb_signup] and [pbd_record] pages, one field of Chosen Multi-Dropdown/Other is autofilling the first value from the list. It doesn’t overwrite the other values and can easily be deleted by the user, but it’s a bit annoying and I can’t figure it out. There’s nothing in the Default box in the database field.
Another similar field doesn’t do this despite being set up in the same way.
Any ideas?
Hi Neil,
This can be caused by having a “space” character in your default field. You won’t know it’s there, but here’s how you get rid of it: on the Manage Database Fields page, find your misbehaving dropdown, type a space (or anything) into the default value, then clear it out so there is nothing there. This forces it to save the empty setting and clear out the space when you save the fields.
I have a fix for this in the next update.
Thanks Roland – but it doesn’t seem to work. When you say “clear”, you just mean type something in that default field then delete it again, and update fields?
Yes, that’s it. making a change, any change, tells the page you’re editing that field, then clear out the “default” setting…that is make sure there is nothing in that space.
anyway, the latest version of Participants Database fixes this problem.
The Chosen Dropdown types work for me on the search page, but not on the Participant registration ([pdb_record] page. Is there something I’m missing in the setup?
can you send me a link to the page so I can see what it’s doing?
support@xnau.com if you want it private
This is the exact problem I’m having
Have a look at your browser console (developer tools) when you load the [pdb_record] page. There may be a javascipt error preventing the element from working.
I just released an update to the Chosen Dropdown add-on that addresses this issue.
Thanks Roland. No errors are showing for the record page. I’ll wait for wordpress to recognise the update is available and let you know how it goes.
Hi Roland,
Sorry to bother you, but the update isn’t showing as available yet. If I try using the “Check for updates” link in the plugins section of WordPress, it says the plugin is up to date.
Regards,
Michael.
Thanks for bringing this to my attention. It should show up now.
Hi Roland,
I just applied the update and after re-activating the plugin, the issue is indeed resolved. Thanks for your efforts!
regards,
Michael.
Here you go.
https://www.lasersharkdesigns.com.au/details/
The URL is incomplete, is won’t show the form as it is…needs the pid code.
Sorry, do you mean the participant ID code?
The user account I’ve setup to test is testing@testing.com and I’ve temporarily disabled the password requirement to login
If the page isn’t displaying with the previous link, you can login with the test account via the login page:
https://www.lasersharkdesigns.com.au/login and then follow the link to the update account info.
It appears as though you don’t have any options defined for the dropdown fields, and the example you gave me had the correct syntax, so I’m not sure what the problem is… but whatever it is, it’s affecting all your multiselect fields. You say it works if you use a “Chosen Dropdown” element instead of the “Chosen Multi Drodown”?
Hi Roland,
It’s not working for any of the chosen dropdown options. I’ve just configured each selection option to be a different option with the last being the multiselect checkbox option. This last option works just fine. I also tried installing the latest code for jQuery and that hasn’t helped. It does not appear to be picking up the options to display, but they are there (I can send you a screen shot if you like). The basic search / look seems to work just fine though.
Regards,
Michael.
Michael,
It’s not in the javascript. Looking at the source for your page, I can tell by looking at how the element is formed, the original select element is present, but empty in your case. Normally, it would contain all the defined options. So there is something keeping your “values” setting from reading in as an array of values to set up the select element. I know you said it worked as a multi checkbox, but does it work as a multi-dropdown?
At this point, we’ll need to debug it. Do you have you PHP error log set up? There could be something in there to help. What version of PHP are you using?
Hi Roland,
Yes the multiselect drop down is working. The PHP version is currently 5.6, but there are a bunch of options for 5.6 features that are not selected. Is there one in particular that should be enabled?
Cheers,
Michael
No, not in particular. Can you set up your PHP error log and take a look at it after showing the form?
Sorry Roland, I’m not finding the logs or an option for them that shows any of the specific queries in the website backend on the hosting server.
OK, well so far I haven’t been able to duplicate your issue, not sure what’s causing it yet. If you install a PHP error log plugin, you may get more info on what is going on, that would be helpful.
Can you post the exact contents of the “values” parameter of one of the field that isn’t working?
Sorry this is being so difficult Roland. I’ve recently changed the values to see if it may have been an issue with having too many to try and select for some strange reason.
The values are currently test, test2, test3 for all fields. I setup php error logging and got the following when logging into the site and navigating to the update details section where the drop down menus are.
[07-Aug-2017 09:10:54 UTC] PHP Notice: Undefined index: allow_desktop_switcher in /home/lasersha/public_html/wp-content/plugins/mobile-smart/mobile-smart.php on line 919
[07-Aug-2017 09:11:32 UTC] PHP Notice: Undefined index: allow_desktop_switcher in /home/lasersha/public_html/wp-content/plugins/mobile-smart/mobile-smart.php on line 919
[07-Aug-2017 09:11:48 UTC] PDb_List::_setup_iteration list query: SELECT p.id, p.roleplaying_games, p.last_name, p.city, p.country FROM wp_participants_database p ORDER BY p.date_updated DESC
[07-Aug-2017 09:11:48 UTC] PHP Notice: Undefined index: allow_desktop_switcher in /home/lasersha/public_html/wp-content/plugins/mobile-smart/mobile-smart.php on line 919
[07-Aug-2017 09:11:56 UTC] PHP Notice: Undefined index: allow_desktop_switcher in /home/lasersha/public_html/wp-content/plugins/mobile-smart/mobile-smart.php on line 919
nothing there to indicate what the problem is. I do want to understand the problem if possible. Event though I don’t have any other reports like this, it may be a bug in the plugin. Did I ask about the version of Participants Database you’re using?
I should be using the latest. I recently updated the plugin when the latest version was released in the last week or so. WordPress says version 1.9.8
When I look at the database through the PHP admin panel, I can see the values in there too. So it is weird that they aren’t being selected properly.
Sorry, I was looking at the Participant Login version. The DB version is now the one just released, so 1.7.5.5
Hi Roland,
A bit of an update. It works just fine for the combo multisearch page [pdb_search template=multisearch ]. It’s still not working for the [pdb_record] page though. I’ll have a play around with the code and see if I can’t figure out why it works for one, but not the other.
cheers,
Michael.
Hi Roland,
I’m trying to setup a Chosen Multi Dropdown field which is displaying on the participant’s record page. I’ve tried just using standard csv values (e.g. one, two, three, four) and I’ve also tried the following based on the FAQ answer above for optgorup formatting.
Availability::optgroup, Any time::any time, Monday::optgroup, Morning::morning, Afternoon::afternoon, Evening::evening, Tuesday::optgroup, Morning::morning, Afternoon::afternoon, Evening::evening, Wednesday::optgroup, Morning::morning, Afternoon::afternoon, Evening::evening, Thursday::optgroup, Morning::morning, Afternoon::afternoon, Evening::evening, Friday::optgroup, Morning::morning, Afternoon::afternoon, Evening::evening, Saturday::optgroup, Morning::morning, Afternoon::afternoon, Evening::evening, Sunday::optgroup, Morning::morning, Afternoon::afternoon, Evening::evening
There are two issues. The primary one is that none of the values are showing up in the field on the participant Record page when I test and the second is that for the Day example above, it removes all the duplicate options after Monday for Morning, Afternoon and Evening.. The idea behind my example is that a user can select which time(s) of day during the week they can do something.
Cheers,
Michael.
Hi Michael,
Well, first, you can’t have duplicate titles for your values (or, if you don’t use titles, you can’t have duplicate values). I can see what you’re trying to do there, and it makes sense, but it won’t work. It won’t work on the backend either because when values are saved, the optgroup value isn’t part of what is saved. Optgroups are for visual organization only.
One way to get around the limitation is to have two controls: one for the day of the week and one for the time of day.
The other, of course, is to just have a separate unique value for each of the choices.
Ok, that makes sense. The second issue I have been experiencing isn’t resolved though. It doesn’t matter which format I use (single csv entries or the style above), the drop down menus aren’t working. They just say “select an option” and if you click in the field or start typing an option, nothing comes up.
Validation is set to “not required” and I have the CSV, Sortable and Persistent options selected. I’m using the Chosen Multi Dropdown option. If I switch it to a multiple checkbox it works just fine though.
OK, well there could be some kind of conflict with the javascript. Can you give me a link to it so I can see it?