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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:39:31+00:00 2026-05-26T21:39:31+00:00

So I am trying to save a form with CakePHP. Its a fairly simple

  • 0

So I am trying to save a form with CakePHP. Its a fairly simple form, but for some reason, an INSERT statement is never being generated.

Here is a snippet from the Controller:

    public function add($sid = null) {
    if($this->request->is('post')) {
        //The app enters here. debug($this->request->data) confirms the data is there.
        if($this->Date->save($this->request->data)) {
            //debug($this->Date->save($this->request->data)) confirms CakePHP thinks its saving the data
            //however looking at the data, and the MySQL log, an INSERT statement is never attempted.
            //The flash and redirect occur as expected.
            $this->Session->setFlash('Dates Saved!');
            $this->redirect(array('action' => 'school', $sid));
        }
    }
    $this->set('schoolid', $sid);
}

Here is my Model:

<?php
class Date extends AppModel {
    public $name = 'Date';
}

Here is the view:

<?php 
echo $this->Html->script(array(
                            'dhtmlxCalendar/dhtmlxcalendar.js'
                          )); 
echo $this->Html->css(array('dhtmlxCalendar/dhtmlxcalendar.css', 'dhtmlxCalendar/skins/dhtmlxcalendar_dhx_skyblue.css'));
?>
<div style="position:relative;height:380px;">
<?php echo $this->Form->create('Dates'); ?>
<?php echo $this->Form->input('schoolid', array('value' => $schoolid, 'type' => 'hidden')); ?>
<?php echo $this->Form->input('grade', array('options' => array('5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12'))); ?> 
<?php echo $this->Form->input('startreg', array('label' => 'Start Registration Date')); ?>
<?php echo $this->Form->input('endreg', array('label' => 'End Registration Date')); ?>
<?php echo $this->Form->input('lottery', array('label' => 'Lottery Date')); ?>
<?php echo $this->Form->end('Save Dates'); ?>
</div>
<?php echo $this->Html->script(array('Schools/add.js')); ?>

And here is the database:

CREATE TABLE IF NOT EXISTS `dates` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `schoolid` int(2) NOT NULL,
  `grade` int(2) NOT NULL,
  `startreg` datetime NOT NULL,
  `endreg` datetime NOT NULL,
  `lottery` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

If anyone has any idea why this is happening, or what debug steps I can take to try to resolve this, I would appreciate it!

  • 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-26T21:39:32+00:00Added an answer on May 26, 2026 at 9:39 pm

    Looks like you’re not creating your form correctly. You’re attempting to create ‘Dates‘. It should be ‘Date‘. Give this a go:

    <?php echo $this->Form->create('Date'); ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to save some values from a form in CakePHP into a MySQL
I'm trying to save a data in a simple form through Hibernate using struts
hey guys im trying to save a url link in a html form but
Using CakePHP 1.3 I'm trying to save some data to a MySQL database. The
I am trying to setup a simple form using formtastic but running into a
I'm trying to save some users in a custom admin form and I'd like
I am trying to save data to a database on a button push, but
I'm trying to save some XML-Data in my UserSettings (Properties.Settings.Default.UserSettings) in a .NET Winforms
I'm trying to save my the state of a System::Windows::Forms::Form when my application shuts
I am having a form and I am trying to save something. Whenever 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.