Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

Limit number of choice un multiple drop down list

  • nijan
  • nijan
  • OFFLINE
  • Posts: 108
  • Thanks: 1
  • Karma: 0
11 years 8 months ago #220842 by nijan
Hi,

I would like to limit the number of choices in a multiple drop down list.
Do you know a way to do it ?

First I thought to repeat my field x times in my registration form, but I think I is not possible because it can give problem later.

Thanks !

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48459
  • Thanks: 8280
  • Karma: 1443
11 years 8 months ago #220866 by krileon
You can't, that's not how a multiselect input works. You'd need JS or jQuery to force the selection to only a few. You could use CB Auto Actions with a Code action on the registration form display trigger and profile edit display trigger to add your JS/jQuery to the header. You can find examples of such usage at the below search.

www.google.com/search?q=limit+number+of+selections+in+multiselect


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • nijan
  • nijan
  • OFFLINE
  • Posts: 108
  • Thanks: 1
  • Karma: 0
11 years 8 months ago #221395 by nijan
Hi Krileon,

I just installed CB Auto Actions.

I suppose I creata a new auto action for the field "multicheckbox" ?
You speak about header for Register form display and Profile edit display.

Where can I put / test my coding ?
Do you have a illustrated example ?

I'm novice in the Joomla / CB development.

Thanks !

Please Log in or Create an account to join the conversation.

  • nijan
  • nijan
  • OFFLINE
  • Posts: 108
  • Thanks: 1
  • Karma: 0
11 years 8 months ago #221423 by nijan
Hello,

I'm back with another solution I think. I'm working with CB Auto Actions and REGEX on the field value. In fact I will test if my Mutliple Check Box have x Upper case letter.

I'm not sure how the data are stored.

For example if the possible choices are English and French.
What is the string format I need to test

- "EnglishFrench" or "englishfrench" or "English;French", ... ?

In that case I think I can count the words (or separator character) and redirect with a error message to invite the user to adapt his selection. Right ?

Cheers !

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48459
  • Thanks: 8280
  • Karma: 1443
11 years 8 months ago #221479 by krileon
You can't interrupt registration, it'll still push through as code is in place to avoid user cancel during storage (browse close for example). You'd have to try setting a plugin error in a PHP Code action, but no idea if that'd work either, then do the redirect.

Your best approach is to just use a jQuery implementation. You can add the jQuery to the header using CB Auto Actions in a Code action. You'd then use a query action after registration to separate the value by |*| (this is the separator used by CB) and if it surpasses your count remove the last few values that do (all in SQL queries, PHP Code action could work too).

For a full proof solution you're going to need to develop a plugin to extend the multi-select field (see ajax text field, points field, etc.. they all extend existing fields) and add the features to do all this (jQuery to limit selection, PHP on validation side).


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • nijan
  • nijan
  • OFFLINE
  • Posts: 108
  • Thanks: 1
  • Karma: 0
11 years 8 months ago #221557 by nijan
Hi Krileon,

First one, many thnks for your support.
Second ... I've another idea :huh:

Look at this and tell me want about ...

Triggers : onBeforeUserUpdate
Conditional : [cb_languesparlees] is REGEX /(\u){2,}/ (So if more than 2 characters in upper case)
Redirect : http://localhost/Skeleton/index.php/profile-view/userdetails
Message : Vous ne pouvez choisir que 2 langues [cb_languesparlees]

If I try this

Conditional : [cb_languesparlees] is REGEX /English/

If I select English I have my message and the update fails ... so it is exactly want I need. I just need now to implement a more developed REGEX.

Please answer that it will be possible :-).

Thanks !

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum