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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:44:18+00:00 2026-05-13T12:44:18+00:00

So I am creating a form builder. Users will login and then fillout the

  • 0

So I am creating a form builder. Users will login and then fillout the forms that Admins have created. I am using saveAll() in my “data_controller” “add” method.

This works fine and and looks like this:

//debug($this->data); prints the following
//app/controllers/data_controller.php (line 21)

Array
(
    [Datum] => Array
        (
            [0] => Array
                (
                    [bool_val] => 1
                    [field_id] => 56
                    [form_id] => 208
                    [user_id] => 1
                )

            [1] => Array
                (
                    [bool_val] => 0
                    [field_id] => 64
                    [form_id] => 208
                    [user_id] => 1
                )

        )

)
// data_controller.php
// the  add method is like this
  function add() {
    debug($this->data);
    if (!empty($this->data) ) {
      $this->Datum->create();
      if ($this->Datum->saveAll($this->data['Datum'])) {
        $this->Session->setFlash(__('The Datum has been saved', true));
        $this->redirect(array('action'=>'index'));
      } else {
        $this->Session->setFlash(__('The Datum could not be saved. Please, try again.', true));
      }
    }
    $forms = $this->Datum->Form->find('list');
    $fields = $this->Datum->Field->find('list');
    $users = $this->Datum->User->find('list');
    $statuses = $this->Datum->Status->find('list');
    $this->set(compact('forms', 'fields', 'users', 'statuses'));
  }

So that works fine and creates a series of new entries in the “data” table of my MySQL database. My error comes when I try to use “saveAll()” in my “edit” method. I have googled and googled and googled with no luck. All of the articles say that my data structure should be correct, or that is how I am understanding them.

So here is my view. It loops through to output checkboxes and other form elements but we will just look at a simple check box only example.

//field_view_datum.ctp
<?php 
//debug($field_datum);
switch ($field['Type']['name']) {

  case "check box" :
    echo "<p>";
    echo $form->label($field['FieldName'][0]['name']);
    echo $form->hidden('Datum.'.$field_datum['id'].'.id', array('value' => $field_datum['id']));
    echo $form->hidden('Datum.'.$field_datum['id'].'.form_id', array('value' => $formID));
    echo $form->hidden('Datum.'.$field_datum['id'].'.field_id', array('value' => $field['id']));
    echo $form->hidden('Datum.'.$field_datum['id'].'.user_id', array('value' => $userID));
    $booly = ($field_datum['bool_val'] == 0) ? false : true;
    $options = array('checked' => $booly);
    echo $form->checkbox('Datum.'.$field_datum['id'].'.bool_val', $options);




    echo "</p>";
  break;

My view will output the following HTML to the browser.

<p>
  <label for="DatumFieldOne">Field One</label>
  <input type="hidden" id="Datum164Id" value="164" name="data[Datum][164][id]"/>
  <input type="hidden" id="Datum164FormId" value="208" name="data[Datum][164][form_id]"/>
  <input type="hidden" id="Datum164FieldId" value="56" name="data[Datum][164][field_id]"/>
  <input type="hidden" id="Datum164UserId" value="1" name="data[Datum][164][user_id]"/>
  <input type="hidden" value="0" id="Datum164BoolVal_" name="data[Datum][164][bool_val]"/>
  <input type="checkbox" id="Datum164BoolVal" value="1" checked="checked" name="data[Datum][164][bool_val]"/>
</p>
<p>
  <label for="DatumFieldTwo">Field Two</label>
  <input type="hidden" id="Datum165Id" value="165" name="data[Datum][165][id]"/>
  <input type="hidden" id="Datum165FormId" value="208" name="data[Datum][165][form_id]"/>
  <input type="hidden" id="Datum165FieldId" value="64" name="data[Datum][165][field_id]"/>
  <input type="hidden" id="Datum165UserId" value="1" name="data[Datum][165][user_id]"/>
  <input type="hidden" value="0" id="Datum165BoolVal_" name="data[Datum][165][bool_val]"/>
  <input type="checkbox" id="Datum165BoolVal" value="1" name="data[Datum][165][bool_val]"/>
</p>

So then when I submit the form I get the following error:

Fatal error: Call to a member function getColumnType() on a non-object in /cake/libs/model/model.php on line 949

The data I am passing and my controller method look like this:

    //debug($this->data['Datum']); prints the following
    app/controllers/data_controller.php (line 39)

    Array
    (
        [164] => Array
            (
                [id] => 164
                [form_id] => 208
                [field_id] => 56
                [user_id] => 1
                [bool_val] => 1
            )

        [165] => Array
            (
                [id] => 165
                [form_id] => 208
                [field_id] => 64
                [user_id] => 1
                [bool_val] => 1
            )

    )

//data_controller.php

  function edit($formid = null) {
    debug($this->data['Datum']);
    if (!empty($this->data) ) {
      if ($this->Datum->saveAll($this->data['Datum'])) {
        $this->Session->setFlash(__('The Datum has been saved', true));
        $this->redirect(array('controller' => 'forms', 'action'=>'index'));
      } else {
        $this->Session->setFlash(__('The Datum could not be saved. Please, try again.', true));
        $this->redirect(array('controller' => 'forms', 'action'=>'view', 'id' => '$formid'));
      }
    }
  }

Any help that you can give would be much appreciated I have done tons of searching and not found the correct answer. Sorry if this post is a bit long winded.
Thanks,
Devin

[EDIT]

In case you need to look at my model or my table structure.

//Model 
//datum.php 
// a basic model nothing unusual here 
<?php 
class Datum extends AppModel { 
  var $name = 'Datum'; 

  var $belongsTo = array( 
    'Form' => array( 
      'className' => 'Form', 
      'foreignKey' => 'form_id', 
      'conditions' => '', 
      'fields' => '', 
      'order' => '' 
    ), 
    'Field' => array( 
      'className' => 'Field', 
      'foreignKey' => 'field_id', 
      'conditions' => '', 
      'fields' => '', 
      'order' => '' 
    ), 
    'User' => array( 
      'className' => 'User', 
      'foreignKey' => 'user_id', 
      'conditions' => '', 
      'fields' => '', 
      'order' => '' 
    ), 
    'Status' => array( 
      'className' => 'Status', 
      'foreignKey' => 'status_id', 
      'conditions' => '', 
      'fields' => '', 
      'order' => '' 
    ) 
  ); 
} 

?> 
//this is from my latest schema snapshot 
  var $data = array( 
    'id' => array('type' => 'integer', 'null' => false, 'default' => 
NULL, 'key' => 'primary'), 
    'form_id' => array('type' => 'integer', 'null' => true, 'default' 
=> NULL), 
    'field_id' => array('type' => 'integer', 'null' => true, 'default' 
=> NULL), 
    'user_id' => array('type' => 'integer', 'null' => true, 'default' 
=> NULL), 
    'status_id' => array('type' => 'integer', 'null' => true, 
'default' => NULL), 
    'value' => array('type' => 'text', 'null' => true, 'default' => 
NULL), 
    'file_path' => array('type' => 'string', 'null' => true, 'default' 
=> NULL), 
    'bool_val' => array('type' => 'boolean', 'null' => true, 'default' 
=> '0'),     // I am using MySQL so this is a tinyint(1) 
    'created' => array('type' => 'datetime', 'null' => true, 'default' 
=> NULL), 
    'modified' => array('type' => 'datetime', 'null' => true, 
'default' => NULL), 
    'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' 
=> 1)) 
  ); 

[EDIT]

So I did as one Poster suggested and this is what I got when putting “debug($model);” on cake/libs/model/model.php (line 949):

cake/libs/model/model.php (line 949)

data //this being what debug() returns

Fatal error: Call to a member function getColumnType() on a non-object in /cake/libs/model/model.php on line 950

I might see what is wrong my model name is Datum or datum.php not data I have no obvious solution in my head, this is a bit deep in Cake for me. Any Suggestions?

I just took a look at my “view” method with the same debug statement and it outputs “Datum” and not “data” like I get from my “edit” method. Just in case that is helpful to anyone.

  • 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-13T12:44:19+00:00Added an answer on May 13, 2026 at 12:44 pm

    The correct answer was delivered in the CakePHP group, see:

    http://groups.google.com/group/cake-php/browse_thread/thread/759c93f04a626c5b#

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

Sidebar

Related Questions

No related questions found

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.