Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8420187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:49:26+00:00 2026-06-10T02:49:26+00:00

I have a form with a multi-select input field that returns an array depending

  • 0

I have a form with a multi-select input field that returns an array depending on user’s selection, the user has 12 options to choose from, which means that there’s no more than 12 options to select. Also the user has the freedom to choose more than one option.

So, in the worst case the user will choose 12 options and an array will be POSTed with these options, I shouldn’t accept more than 12 options or less than 1 option.

Anyway, by looking at Codeigniter’s form validation library I didn’t find any rule for dealing with array’s length (maybe *_length works for arrays?)

Also, I did some quick researches but I couldn’t find anything useful, or even related to my problem.

The only solution I have in mind is creating a custom function that checks for array’s length
(using count(Array)) by passing the function with min and max length as a rule, this might work well, but I’m looking for a native way of doing it, Also I’m afraid of “reinventing the wheel.”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:49:27+00:00Added an answer on June 10, 2026 at 2:49 am

    I would not seek to check the length of the posted array data, since you will then need to check that everything submitted actually existed as an option to select anyway.

    So you will automatically be validating the input when you check anything selected was one you could possibly choose from (if you simply unique the array values first).

    You still need a custom function though, as you need to compare the submitted values against what should have been possible to select from. Presumably these values exist in the DB somewhere, so in your custom validation routine, take the input array, unique it in case they for some reason tried to submit the same thing multiple times, then loop through all the submitted items to ensure they ALL exist as options selectable.

    BTW, ‘less than 1 option’ would be the absence of a POST data for the name of the multi-select you’re referring to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm in process creating a form in Plone/PloneFormGen. This form has Multi-Select field that
I have the following multi-select box in a HTML form, where user can select
I have a form select replacement that uses jQuery to show options in a
I have a form that (amongst other things) contains 2 multi-select listboxes. Basically you
I have a form for submitting an article. The form has a category multi-select
I have a listbox (multi-select) in my web form that is populated from a
I have a form that uses a multi select so you can select multiple
We currently have a form with the standard multi-select functionality of here are the
I have a multi-step order form built in this manner: Step 1: Choose category
I have a multi select box in a form. the elements in this select

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.