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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:25:32+00:00 2026-05-19T00:25:32+00:00

Using CakePHP 1.3.6 I’m sure I may have to add code and examples, but

  • 0

Using CakePHP 1.3.6

I’m sure I may have to add code and examples, but I’ll start with this: I have a large form that is create()’d based on a parent model that ‘has many’ of several other models that have fields created in the form.

Several of the ‘child’ models (which are also marked as ‘belongs to’ the parent) have a ‘checked’ field (tinyint 1, checkbox) and a ‘notes’ field (text, textarea input).

From inside one of the child models, if I place debug($this->data); in any of the custom validation callbacks, I get this:

Array
(
    [Preapp120aItem] => Array
        (
            [checked] => 1
            [notes] => 1ere's some notes.
            [agent_id] => 1
        )

)

Where the textarea contains “here’s some notes.” and not “1ere’s…”, as above.

Also, upon doing a saveAll() on the parent, I receive this error, for the child model in question:

Notice (8): Array to string conversion [CORE/cake/libs/model/datasources/dbo_source.php, line 749]
Warning (512): SQL Error: 1054: Unknown column 'Array' in 'field list' [CORE/cake/libs/model/datasources/dbo_source.php, line 684]
Query: INSERT INTO `preapp120d_items` (`checked`, `notes`, `modified`, `created`) VALUES (1, Array, '2011-01-06 08:27:40', '2011-01-06 08:27:40') 

Where part of the stack trace information shows this, about the model:

Preapp120dItem::$Preappform = Preappform object
$fields =   array(
    "checked",
    "notes",
    "modified",
    "created"
)
$values =   array(
    "1",
    array(
    "preappform_id" => "18"
),
"2011-01-06 08:27:40",
"2011-01-06 08:27:40"
)

How or why is the notes field being populated with that array?

The parent model is called a ‘preappform’, and indeed, its ID is 18… but…?

Update 1:

As requested, here’s some code from the view.

Variable used later, placed before form:

$default_notes_element_options = array(
    'type' => 'textarea',
    'rows' => '2', 
    'class' => 'text' 
);  

Form Create:

<?php echo $form->create('Preappform', $default_form_create_options); ?>
<?php echo $form->input('Preappform.id', array('type'=>'hidden', 'value'=>$the_form['Preappform']['id'] )) ?>

Preapp120aItem fields

<td nowrap="nowrap"><?php echo $form->input('Preapp120aItem.checked', array('label'=>array('text' => 'Request this item', 'class' => 'checkbox-label'))) ?></td>
<td width="327">
    <?php echo $form->input('Preapp120aItem.notes', $default_notes_element_options); ?>
    <?php echo $form->input('Preapp120aItem.agent_id', array('type' => 'hidden', 'value' => '1' )); ?>
</td>

Update 2:

HTML as rendered, for the Preapp120aItem model.

<tr>
    <td>120A</td>
    <td nowrap="nowrap">
        <input type="hidden" name="data[Preapp120aItem][checked]" id="Preapp120aItemChecked_" value="0" />
        <input type="checkbox" name="data[Preapp120aItem][checked]" value="1" id="Preapp120aItemChecked" />
        <label for="Preapp120aItemChecked" class="checkbox-label">Check this box</label>
    </td>
    <td width="327">
        <textarea name="data[Preapp120aItem][notes]" rows="2" class="text" cols="30" id="Preapp120aItemNotes" ></textarea>
        <input type="hidden" name="data[Preapp120aItem][agent_id]" value="1" id="Preapp120aItemAgentId" />          
    </td>
</tr>
  • 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-19T00:25:33+00:00Added an answer on May 19, 2026 at 12:25 am

    My bad

    I may not have made it clear enough that ‘Preappform’ was a parent model, that ‘hasMany’ ‘Preapp120aItem’ children.

    Thus, in the form, despite the fact that I only intend to save one at a time, the View should have contained the following, in place of the similar code found in the original question:

    <td nowrap="nowrap"><?php echo $form->input('Preapp120aItem.0.checked', array('label'=>array('text' => 'Request this item', 'class' => 'checkbox-label'))) ?></td>
    <td width="327">
        <?php echo $form->input('Preapp120aItem.0.notes', $default_notes_element_options); ?>
        <?php echo $form->input('Preapp120aItem.0.agent_id', array('type' => 'hidden', 'value' => '1' )); ?>
    </td>
    

    The subtle difference being the “0” (zero) between Model name and Field name. I knew to do this when saving multiple of a related item, but not when saving one.

    As for how/why Cake was somehow overwriting what ended up in the model’s $this->data with a “1” for the first position character: I have no stinkin’ idea, and I don’t intend to find out.

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

Sidebar

Related Questions

Using CakePHP 1.3 , I have a (working) form that has dynamically created form
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using CakePHP 1.3 , I post a form which correctly fills in $this->data .
Using CakePHP 1.3 I have a fairly large model in CakePHP, and I'd like
I am using cakephp. I have a form with an element array. For ex:-
Using cakephp, I have a generic address table, which I want to link to
Using CakePHP: I have a many-to-one relationship, let's pretend it's many Leafs to Trees.
Using CakePHP 1.3, I have the following layout: /srv/www/_cakephp13/ /app/ /cake/ /plugins/ /vendors/ etc...
Using CakePHP, I created select-option form element with: echo $form->select('items', $numeration , array('selected' =>
hi i am using cakephp for my project but i am fetching problem when

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.