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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:50:01+00:00 2026-06-16T11:50:01+00:00

So, I have a form in CakePhp using it’s Formhelper. There are two associated

  • 0

So, I have a form in CakePhp using it’s Formhelper. There are two associated models in this form: Booking & Guest. The database tables seem to be setup correctly since the page populates the values accurately enough through the associations in the model.

When saving my form data, the Booking information saves but not the Guest information. I’ve simplified the code in the snippets below. Any ideas what I’m doing wrong?

Model

class Booking extends AppModel {
public $name = "Booking";

/*Associations Section*/
public $belongsTo = array('Property','Bookingsource');
public $hasMany = array('Payment','Occupant','Bookingfee');
public $hasAndBelongsToMany = array(
    'Addon',
    'Guest' => array(
        'unique' => FALSE
    )
);
}

Controller

public function edit($id) {
    if ($this -> request -> is('post')) {
        if ($this -> Booking -> saveAll($this -> request -> data)) {
            $this -> Session -> setFlash('Booking Edited Successully!', "goodflash");
        } else {
            $this -> Session -> setFlash('Oops Something went wrong!', "badflash");
        }
    } else {
        $this->data = $this -> Booking -> findById($id);
        $this -> set('bookingid', $id);
    }
}

View

<?php
echo $this->Form->create("Booking", array('type' => 'post'));
echo $this -> Form -> hidden('Booking.id');
echo $this -> Form -> input('Booking.property_id');
echo $this -> Form -> input('Booking.checkin');
echo $this -> Form -> input('Booking.checkout');
echo $this -> Form -> input('Guest.0.firstname');
echo $this -> Form -> end("Submit");
?>

When looking at the SQL that’s being processed, I don’t see anything to suggest an attempt to edit the Guest table attached to my model.

5   UPDATE `cake_bookingsystem`.`bookings` SET `id` = '10000', `property_id` = '01', `checkin` = '2012-11-10', `checkout` = '2012-12-13' WHERE `cake_bookingsystem`.`bookings`.`id` = '10000'       0   0   8
6   COMMIT      0   0   8
  • 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-16T11:50:03+00:00Added an answer on June 16, 2026 at 11:50 am

    Try adding the id field of the guest record also in your view:

    <?php
    echo $this->Form->create("Booking", array('type' => 'post'));
    echo $this -> Form -> hidden('Booking.id');
    echo $this -> Form -> input('Booking.property_id');
    echo $this -> Form -> input('Booking.checkin');
    echo $this -> Form -> input('Booking.checkout');
    echo $this -> Form -> input('Guest.0.id');
    echo $this -> Form -> input('Guest.0.firstname');
    echo $this -> Form -> end("Submit");
    

    ?>

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

Sidebar

Related Questions

Using CakePHP 1.3 we have a booking system for hotel rooms. A check-availability form
I'm using cakephp. I have a form where one of the inputs is there
I'm using CakePHP 1.2.4 and I have two search filters in a search form
I have just started using cakePHP 2.1. After submiting a form. If there is
I'm developing a site using the CakePHP framework. I have a form which shows
I have form in my page, I am using ajax.beginform(). Inside this form I
I'm trying to create a form using Cakephp's FormHelper class. The form needs to
I am trying to implement form validation using cakephp models. Here are my code
I have a simple cakephp form WITH validation that submits to a database. It
I have a form that includes an hour and minute drop down using this:

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.