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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:45:42+00:00 2026-05-25T18:45:42+00:00

I have a form in CakePHP that has two live-search text input. Each one

  • 0

I have a form in CakePHP that has two live-search text input. Each one of them updates the value of a hidden field when the user selects a result. The model is called Record, and the attributes involved are

  • budget_id
  • program_id
  • concept_id

I have created a form using the FormHelper in this way:

...
<?php echo $this->Form->create('Record') ?>
<h1>Create a record</h1>

<?php echo $this->Form->hidden('Record.budget_id', array('value' => $budget['Budget']['id'])) ?>

<?php echo $this->Form->hidden('Record.program_id') ?>
<?php echo $this->Form->input('Record.program_id_search', array(...)) ?>

<?php echo $this->Form->hidden('Record.concept_id') ?>
<?php echo $this->Form->input('Record.concept_id_search', array(...)) ?>

<?php echo $this->Form->submit('Send') ?>
<?php echo $this->Form->end(); ?>
...

As you can see, the input fields that store the model attributes are hidden. The live-search boxes are configured with the jQuery’s autocomplete plugin.

Following the CakePHP manual recommendations I have disabled the two extra fields in beforeFilter method, so that the Security component ignores them and the form passes validation:

public function beforeFilter() {
  $this->Security->disabledFields = array(
    'Record.program_id_search',
    'Record.concept_id_search',
  );
}

It seems that CakePHP gets angry whenever I change the value of hidden inputs from Javascript and it sends me to the blackhole method. That’s OK according to documentation.

But what surprises me is that the Security component keeps ignoring my disabledFields settings.

I’ve been searching in several web sources and everybody point to the disabledFields options. But it does not work for me.

Any suggestions?

Thanks!!

UPDATE

I have found a workaround but it’s really really ugly. I have replaced the hidden input fields with regular select fields, but setting the CSS display property as none.

This way the Security component does not complain anymore, and the user keeps viewing a couple of live-search boxes.

I don’t understand why changing a select with Javascript it’s ok, but changing a hidden input not.

  • 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-05-25T18:45:43+00:00Added an answer on May 25, 2026 at 6:45 pm

    It happens because the Security Component locks the hidden fields, saving in the hash not just their name but also their value. Therefore when you change their value, you make the whole form invalid. The only solution is to switch those fields from hidden to normal field, wrapped inside a display:none; div.

    Another way would be to disable the checks on that field, but the code you posted isn’t the right way to do it. You should instead specify the fields during the configuration of the component, like this:

    var $components = array('Security' => array(
        'blackHoleCallback' => 'callback',
        'requireAuth' => array('action1', 'action2'),
        'allowedControllers' => array('controller'),
        'allowedActions' => array('action1', 'action2'),
        'disabledFields' => array('Record.program_id_search', 'Record.concept_id_search')
        )
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have form with one input for email and two submit buttons to subscribe
I have got a simple HTMl form with one field as follows: <input type=text
Using CakePHP 1.3 , I have a (working) form that has dynamically created form
I have a single model in CakePHP that has multiple forms on different pages
I have a simple cakephp form WITH validation that submits to a database. It
I have a form which has action=process.php . Inside that php file there is
One of the things I like with cakePhp, is that we can easily have
I have an HTML document with the following form: <form> <input type=text id=price> <input
I'm using cakephp. I have a form where one of the inputs is there
I have a a simple group of checkboxes generated by cakePHP's form echo $form->input('Interest.interest_id',

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.