Jump to content
haitlaoussine

Dropdown select multiple

Recommended Posts

Hello, 

I'm developing a plugin forWHMCS,  I need to know if there is a way to have a dropdown with select multi in WHMCS ?

I have set the 'Type' => 'dropdown', and the 'Multiple' => true, and the frontend is good, but is doesn't save the values in the database

Thank's

Share this post


Link to post
Share on other sites

Nope.

Quote

Supported field types are “text”, “password”, “yesno” (checkboxes), “textarea”, “dropdown” and “radio”

IMO don't even start using _config() function. As you can see it is already limited and with time your addon could become so big and complex that you'll need to find alternatives. Moreover it doesn't support conditional options (e.g. Select A show B hide C).

Create a dedicated table (e.g. blabla_config) where you can store anything you need freely. This way you can create a dedicated page/interface if to configure your addon with text, password, multiselect, toggle, file uploader (...) inputs.

Edited by Kian

Share this post


Link to post
Share on other sites

I agree with Kian, but:

1 hour ago, Kian said:

Moreover it doesn't support conditional options (e.g. Select A show B hide C).

This is technically possible by checking which option was saved. Of course, the condition is only processed when the option was saved, so it is probably a bit cumbersome for the end user.
If you are a hardliner, you could use javascript to modify the output, but this is overkill. A configuration page inside yourmodule_output is the easiest way.

Share this post


Link to post
Share on other sites
11 hours ago, string said:

Of course, the condition is only processed when the option was saved, so it is probably a bit cumbersome for the end user

Yeah, it's impractical 😔 anyway I was thinking about a more complex scenario. For example think about Country/Region dropdown combo. Select Italy and get Italian regions, select Germany and get German ones, select Morocco and instead of a dropdown with regions you have a text field. Not to mention you can end up with things like Germany + Italian region stored in database 😭

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated