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

The Archive Base Latest Questions

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

I am using cakePHP 2.0 and am busy with a user management form for

  • 0

I am using cakePHP 2.0 and am busy with a user management form for my site. The issue is that when I recall the user information row from the database, it reads the password in its ecrypted form and then populates the form element with a long string (I am assuming the encrypted password).

On save, my validation rules break because I limit to 8 characters (which is a good thing because I dont want to save the encrypted version of a password).

I also cannot leave the field blank because it may result in people saving and failing the validation rules again (no password entered)

What is the best way to overcome this? I thought about replacing the row’s populated password with an 8 character dummy password and do a validation check, however, that will not work because a) someone MAY use the same password and b) I will need to do another find to get the original password again which does not make sense.

Any help?

 // Controller EDIT:
 public function edit($id = null) {
    $this->User->id = $id;
    if(!$this->User->exists()) {
       $this->Session->setFlash(__('The user does not exist'));
       $this->redirect(array('action' => 'index'));
    } else {
        if($this->request->is('post') || $this->request->is('put')) {
            if($this->User->save($this->request->data)) {
                $this->Session->setFlash('The user has been updated','default',array('class'=>'success'));
                $this->redirect(array('action' => 'index'));
            } else {
                $this->Session->setFlash(__('The user could not be saved. Please, try again.'));
            }
        }
        $this->request->data = $this->User->read(null, $id);
        $userTypes = $this->User->UserType->find("list");
        $userStatuses = $this->User->UserStatus->find("list");
        $this->set(compact("userTypes","userStatuses"));
    }

}

 // HTML Form:
 <?php echo $this->Form->create('User');?>
<fieldset>
    <legend><?php echo __('Modify User '); ?></legend>
    <h3><?php echo $this->Html->link("Return to user index",array("controller" => "users","action" => "index")); ?></h3>
<?php
    echo $this->Form->input('username');
    echo $this->Form->input('password',array("id" => "profilePassword","empty" => true, "autocomplete" => "off"));
    echo $this->Form->input('company');
    echo $this->Form->input('first_name');
    echo $this->Form->input('last_name');
    echo $this->Form->input('telephone');
    echo $this->Form->input('fax');
    echo $this->Form->input('user_status_id');
    echo $this->Form->input('user_type_id');
?>
</fieldset>
 <?php echo $this->Form->end(__('Update'));?>
  • 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-11T11:59:44+00:00Added an answer on June 11, 2026 at 11:59 am

    you should unset password if it’s empty (user didn’t wanted to change it)

    before you save your model try:

    if(empty($this->request->data[$this->alias]['password'])) {
        unset($this->request->data[$this->alias]['password']);
    }
    

    this way if user wants to change the password it will be validated, and if he doesn’t change it it will not update and will pass validation. You also can not require password field in validation rules or it will never pass in case user don’t change the password. Instead set rules like length limit ect…

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

Sidebar

Related Questions

I am using cakephp's form for an HABTM relationship between User and Event. There
Using CakePHP 1.3 , I have a (working) form that has dynamically created form
Im using cakephp 2.0 and i have data submitted that i want to cleanup,
I'm using CakePHP 2.1 I have following fields in database. id views max_views I
I have a site set up using CakePHP and MySQL and I want to
Using cakephp: I create a website & after upload my site to main server
Using CakePHP, I created select-option form element with: echo $form->select('items', $numeration , array('selected' =>
Using CakePHP, I am finding that I'm duplicating some code between controller actions. I
We are using Cakephp framework version 2.0.6 The site is supposed to allow an
Using CakePHP 1.3 I'm trying to save some data to a MySQL database. The

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.