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 7929547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:07:13+00:00 2026-06-03T20:07:13+00:00

I am using cakephp and trying to pass an array from the view to

  • 0

I am using cakephp and trying to pass an array from the view to the controller, i do generate a checkbox of names, the user should select some names and submit his request.

echo $this->Form->create('Task');
echo ($this->Form->input('sentTo', array('type' => 'select', 'multiple' => 'checkbox',        'options' => $options)));
echo $this->Form->end('submit');

the problem is the sentTo checkbox will return the indices checked in $this->request->data i don’t want to do that, i want to return the ids of the users which i can get in the view. so i want to replace these indices with other numbers, i tried to manually overwrite $this->request->data but the changes become only visible in the view and not the controller.

If you please know how to alter the request data before sending it to the controller, or pass arrays from the view to the controller try to help me (i don’t want to use the session or the cache)

Regards

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

    If I understood your problem correctly, and from the comments above, this is your problem:

    $j = 0;
    foreach ($users as $user) { 
        $options[$j] = $user['u1']['username'];
        $j++;
    }
    

    If you are using that for the checkboxes then change that to:

    foreach ($users as $user) { 
        $id = $user['u1']['id'];
        $options[$id] = $user['u1']['username'];
    }
    

    Although I don’t get what 'u1' is.

    In short: set the keys of the options array to the id of the records.

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

Sidebar

Related Questions

I'm using TCPDF in CakePHP and trying to make some background (grey) for few
I'm trying to create an XML sitemap using CakePHP, from a table which has
Using CakePHP 1.2, I am trying produce a GROUP BY query: SELECT `categories`.*, COUNT(`entities`.id)
I am using cakephp. I am trying get data from facebook using file_get_contents. I
Using CakePHP 1.3 I'm trying to save some data to a MySQL database. The
I'm trying to migrate my app from cakephp 2.0 to 2.1. I've been using
I'm trying to pull some data into my CakePHP site using a REST API.
I am trying to retrieve some data using a combination of jQuery and CakePHP.
I'm trying to use CakePHP's form helper to generate some input elements. The HTML
I'm using cakephp and trying to check if a table has data entered in

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.