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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:14:56+00:00 2026-05-25T12:14:56+00:00

I am building a simple booking system in CakePHP that uses 3 tables to

  • 0

I am building a simple booking system in CakePHP that uses 3 tables to create bookings. They are Clients, Doctors and Appointments. A client and a doctor can have multiple appointments, but an appointment can only have one client and one doctor.

I have built the create and edit client parts fine but struggling to build the create appointment and link them to a doctor and client. I have set up the relationships in the Models and they work fine for pulling data out so I know they work as intended.

So for example if I want to book an appointment for client with ID of 1 I would visit: /appointments/add/1 And then in the view it will have something like:

   <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" />
            </li>
        </ul>
    </fieldset>

    <?php echo $this->Form->end(); ?>

So as you can see I want to display the name of the client in the header using the passed id (which is called client_id in the appointments table). And you should be able to choose a doctor name from a drop down.

This is my controller action so far:

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

    $this->set('doctors', $this->Appointment->Doctor->find('list'));

    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'));
        }
    }
}

However my list of doctors is NOT being created… Can anyone help? Thanks

EDIT: also noticed that everytime I submit the form it overrides the same appointment everytime with the ID of 1. SO it doesn’t create a NEW appointment… any ideas?

  • 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-25T12:14:56+00:00Added an answer on May 25, 2026 at 12:14 pm

    Your client name is not displayed because you are not setting the client data in your controller.

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

    Not sure, if this will solve the missing doctors’ list problem, but you’re missing the model name in the create method

    $this->Form->create('Appointment', ...);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a simple Android project in eclipse that uses the google-api-java-client .
I am building a simple Django app that will use scribd to display documents.
I'm building a simple ice sliding puzzle to test uses of allegro. So far
If you are building a simple website using just simple HTML/CSS/Javascript that has say
I am building a simple book check out application. One of the things that
I building a simple class that is supposed to mimic the functionality of the
I am building a simple client-server program , I have in main : FTPClient
I'm building a simple C++ program and I want to temporarily substitute a system
I building a simple search feature that checks against a column desc in mysql
I'm building a simple interpreter of a language that i'm developing, but how i

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.