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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:37:55+00:00 2026-05-25T13:37:55+00:00

I have built a CakePHP app for creating appointments against clients and everytime I

  • 0

I have built a CakePHP app for creating appointments against clients and everytime I try to create an appointment for a client it always overwrites any existing appointment with the same ID of 1. The ID is set to AI in the database so it should auto increment but it’s not.

Here is my controller action:

function admin_add($client_id)
{
    $this->set('client_id', $client_id);

    $this->set('client', $this->Appointment->Client->find('first', array('conditions' => array('Client.id' => $client_id))));

    $this->set('doctors', $this->Appointment->Doctor->find(
      'list',
      array(
        'fields' => array('Doctor.name'),
        'order' => array('Doctor.firstname', 'Doctor.lastname')
      )
    ));

    if (!empty($this->data))
    {
        if ($this->Appointment->save($this->data))
        {
            $this->Session->setFlash('Your post has been saved.');
            $this->redirect(array('admin' => true, 'controller' => 'appointments', 'action' => 'index'));
        }
    }
}

and this is my model:

class Appointment extends AppModel
{
    var $name = 'Appointment';

    var $useTable = 'appointments';

    var $belongsTo = array('Client','Doctor');
}

and finally my view for the form:

<h1>Book Appointment <em>for</em> <?php echo $client['Client']['firstname'] . " " . $client['Client']['lastname']; ?></h1>

<?php echo $this->Form->create('Appointment', array('url' => array('admin'=>true,'controller'=>'appointments','action'=>'add',$client_id))); ?>

<fieldset id="post-form">
    <ul>
        <li>
            <?php echo $this->Form->input('client_id',array('type'=>'hidden','value'=>$client_id)); ?>

            <?php echo $this->Form->input('doctor_id',array('label'=>'<strong>Choose Doctor</strong>'),$doctors); ?>
        </li>
        <li>
            <?php echo $this->Form->input('datetime',array('label'=>'<strong>Date and Time</strong>')); ?>
        </li>
        <li>
            <?php echo $this->Form->input('treatment',array('label'=>'<strong>Treatment</strong>')); ?>
        </li>
        <li class="sep clearfix">
            <input class="submit" type="submit" name="submit" value="Book Appointment" />
            <?php echo $this->Html->link('Cancel',array('admin'=>true,'controller'=>'clients','action'=>'view',$client_id)); ?>
        </li>
    </ul>
</fieldset>

<?php echo $this->Form->end(); ?>
  • 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-25T13:37:56+00:00Added an answer on May 25, 2026 at 1:37 pm

    Adding this to the view fixes the problem:

    <?php echo $this->Form->input('id', array('type' => 'hidden')); ?>

    but why do I need to do this? As clearly the database was able to fill the field with an integer it just didn’t auto increment :/

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

Sidebar

Related Questions

I have built a CakePHP app that creates appointments which have both a client
I have a cakePhp application built, and now I'm creating a simple blog based
I have built a cakephp app that needs the user to login or register(for
I have built a simple C#.Net app on a M/C with only .Net FX
I have built a MS Access 2007 application that can create reports files in
I have built an application in CakePHP that lists businesses. There are about 2000
I am learning the Model relationship types in cakephp. I have built two tables
I'm working on a French language site built in CakePHP. I have tried multiple
I have built and app which does random stuff and I want to collect
This site is built using CakePHP 1.2* I have an element that needs to

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.