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

  • SEARCH
  • Home
  • 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 8578109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:18:43+00:00 2026-06-11T20:18:43+00:00

I want to set the multi selection to my multi list box. I have

  • 0

I want to set the multi selection to my multi list box.

I have two results in my view page.

$inr1 = 0;
$arr1 = array();
$str_arr = '';
foreach ($result as $rows){
    $inr1 = $rows['Employees']['employee_id'];
    $arr1[$inr1] = $rows['Employees']['first_name'].' '.$rows['Employees']['last_name'];
    $str_arr = $str_arr.$inr1.',';
}
$str_arr = substr($str_arr,0,-1);
//print_r($arr1);

$inr = 0;
$arr = array();
foreach ($options as $option){
    $inr = $option['Employee']['employee_id'];
    $arr[$inr] = $option['Employee']['first_name'].' '.$option['Employee']['last_name'];
}

//print_r($arr);

echo $this->Form->input('emp_id_one', array(    'options' => array( $arr),
        'empty' => '(choose one)',
        'div'=>'formfield',
        'error' => array(   'wrap' => 'div',
                            'class' => 'formerror'
                        ),
        'label' => 'Team Members',
        'type' => 'select', 'multiple' => true,
        'selected' => $arr1,
        'style' => 'width:210px; height:125px;',

));

But the values in $arr1 not selected in the list box.

The $arr1 have the selected values.

The $arr have the options to the list.

The problem is that the selction is not working..There have no selection…

How can i do this?

If there is any problem in my code..?

  • 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-11T20:18:44+00:00Added an answer on June 11, 2026 at 8:18 pm

    Finally i solved my problem by chaing some code:

    Add the one line of code after this $str_arr = substr($str_arr,0,-1);‘.
    That is….

    $str_arr = substr($str_arr,0,-1);
        $sel = explode(',',$str_arr);
    

    Then change the name of variable as like this :

    echo $this->Form->input('emp_id_one', array(    'options' => array( $arr),
            'empty' => '(choose one)',
            'div'=>'formfield',
            'error' => array(   'wrap' => 'div',
                                'class' => 'formerror'
                            ),
            'label' => 'Team Members',
            'type' => 'select', 'multiple' => true,
            'selected' => $sel,
            'style' => 'width:210px; height:125px;',
    
        ));
    

    Now the values in $sel is selected in the multi list

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

Sidebar

Related Questions

I have a list view with multi columns... Want to change the background color
I have some models and I want to generate a multi-selection form from this
I have a multi-page template set up. The first page has a set of
I have a multi-dimensional array similar to the example below that I want to
I have a multi-dimensional array and what i want is in each second degree
I have a list with 40 results in a list box that can be
I want to know what framework/Interface/API's Set is best to use to create multi-process
i want set the visibility to itemized overlay in map view. if the zoom
My question is : I have an EditText and I want set a margin
i have a problem, i want set text of a UILabel or UItextView or

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.