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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:58:05+00:00 2026-06-08T19:58:05+00:00

I am on CakePHP 1.2 at the office and, following my last question ,

  • 0

I am on CakePHP 1.2 at the office and, following my last question, I would like to send the array key of the selected option in a SELECT input instead of sending its actual value. I have tried a few things with the Model::beforeSave() function, without success.

I am aware that the data posted by CakePHP does not include the whole array, but only the selected value.
Here is what the function looks like at the moment:

function beforeSave(){
    $this->Post->set('category_id', = array_keys($this->data['Annonce']['category_id']);
    # debug($this->data);
}

Would there be a way to store the array keys into an hidden input and changing this input value depending on the user’s selected item in the SELECT input, and to also omit sending the user’s input but still send the hidden value?

  • 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-08T19:58:07+00:00Added an answer on June 8, 2026 at 7:58 pm
    $categories = Set::combine($categories,'{n}.categories.id', '{n}.categories.nom');
    

    This did it for me… CakePHP assigns the array_keys() values automatically to the value field of the input.

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

Sidebar

Related Questions

In CakePHP there is function like=> echo $this->Html->link('name',array(...)); Is there anything like that in
In CakePHP view, When I try this code <?php echo $form->input('download_link', array('type'=>file)); ?>> whose
CakePHP APP folder contains following folders: - config - controllers - libs - locale
In cakephp, I used $rNo array in WHERE clause. $rooms =$this->find('all',array( 'conditions'=>array(NOT=>array('Room.id'=>$rNo)), 'group'=>array('Room.room_type_id'))); Now,
Using CakePHP 1.3 there are named parameters in the URL like .../name:value/... These are
Using CakePHP 1.3, I have the following layout: /srv/www/_cakephp13/ /app/ /cake/ /plugins/ /vendors/ etc...
In CakePHP, it seems like a lot of functions can take their arguments as
In CakePhp 1.3: orry if this question is stupid, but I really don't know
In CakePHP, how do you select just a subtree in a model which actsAs
In CakePHP 2 I use @ ichikaway 's MongoDB plugin like this: public $default

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.