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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:55:29+00:00 2026-06-09T22:55:29+00:00

Hi all I’m trying to create a form where a user can create a

  • 0

Hi all I’m trying to create a form where a user can create a new user which will have the same account_id as the person creating the user.

currently my page is displaying the correct account_id in the form but when we submit the form to the database it saves as the wrong thing.

here is my function

      function add_Employee(){

        $accounts=$this->User->find('list', array(
        'fields'=>array('account_id'),
        'conditions' => array(
        'User.id' => $this->Auth->user('id'))));

    if($this->request->is('post')){
    $this->User->create(); 
    if ($this->User->save($this->request->data)) 
    { 
        $this->Session->setFlash('The user has been saved');  
        $this->redirect( array('controller'=>'Users','action' => 'index_admin')); 
    }
    else { $this->Session->setFlash('The user could not be saved. Please, try again.'); } 
    }
    $this->set('accounts',$accounts);


  }

and the view

  <h2>Add Employee</h2>
<p>Add a new Employee here, please enter their details below.</p>
<?php
echo $this->Form->create('User', array('action'=>'add_Employee'));
echo $this->Form->input('username',array('label'=>'Username: '));
echo $this->Form->input('password',array('label'=>'Password: '), array('type'=>'password'));
echo $this->Form->input('password_confirmation',array('label'=>'Confirm: '), array('type'=>'password'));
echo $this->Form->input('email',array('label'=>'Email: '));
echo $this->Form->input('title',array('label'=>'Title: '));
echo $this->Form->input('firstname',array('label'=>'First Name: '));
echo $this->Form->input('surname',array('label'=>'Surname: '));
echo $this->Form->input('active', array('default'=>true, 'type'=>'hidden'));
echo $this->Form->input('account_id', array('value'=>$accounts['User']['account_id']));
echo $this->Form->input('access_level', array(
    'label' => 'Access Level:', 
    'options' => array('1'=>'Employee','2'=>'Adminstrator')));
echo $this->Form->end('Submit');
?>
  • 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-09T22:55:31+00:00Added an answer on June 9, 2026 at 10:55 pm

    you have to put account id as value in form :

    In controller:
    
     $accounts=$this->User->find('first', array(
        'conditions' => array(
        'id' => $this->Auth->user('id'))));
     $this->set('account',$accounts);
    
    In view :
    echo $this->Form->input('account_id', array('label'=>'Account','value'=>$account['User']['account_id']));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, I am trying to create a table to receive user inputs (UGC). This
I have a text area in my form which accepts all possible characters from
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
All, I have a form with a MultiValueField that almost works. It uses a
All, I have a shell script on Mac OS X which uses the mdls
All, I have the following class so to check to see if the form
All I want is to make a simple user password login. I have put
all creating a cakephp(using 2.1.2) page. we prompt the user to enter how many
All I'm trying to do is something fairly simple : Create a class (let's
All- I am trying to get the user's current location than display that on

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.