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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:21:45+00:00 2026-05-30T13:21:45+00:00

I’ve have this DB Model http://www.dropmocks.com/mBgqjs and I’m using CakePHP to build a simple

  • 0

I’ve have this DB Model http://www.dropmocks.com/mBgqjs and I’m using CakePHP to build a simple application just for learning where I have this add() method:

public function add() {
    if ($this->request->is('post') && is_uploaded_file($this->request->data['Information']['picture']['tmp_name'])) {
        // Handling file uploads
        $upload_avatar_dir = WWW_ROOT . "uploads/avatar/";
        $new_file_name = $this->createRandomString() . substr($this->request->data['Information']['picture']['name'], -4);
        move_uploaded_file($this->request->data['Information']['picture']['tmp_name'], $upload_avatar_dir . $new_file_name);

        $this->request->data['Information']['picture'] = $upload_avatar_dir . $new_file_name;

        $this->Information->create();

        if ($this->Information->saveAssociated($this->request->data)) {
            $this->Session->setFlash(__('The information has been saved'), 'flash_success');
            $this->redirect(array('action' => 'index'));
        } else {
            $this->Session->setFlash(__('The information could not be saved. Please, try again.'), 'flash_error');
        }
    }
    $countries = $this->Information->Country->find('list');
    $this->set(compact('countries'));
}

and this is my add.ctp file:

<div class="information form">
<?php echo $this->Form->create('Information', array('class' => 'form-horizontal', 'enctype' => 'multipart/form-data'));?>
<fieldset>
    <legend><?php echo __('Add Information'); ?></legend>

    <ul class="nav nav-tabs">
        <li class="active"><a href="#personal" data-toggle="tab"><?php echo __('Personal') ?></a></li>
        <li><a href="#extra" data-toggle="tab"><?php echo __('Other Information') ?></a></li>
    </ul>

    <div class="tab-content">
        <div class="tab-pane active" id="personal">
            <div class="row">
                <div class="span4">
                    <?php
                        echo $this->Form->input('name', array('label' => __('Name')));
                        echo $this->Form->input('lastname');
                        echo $this->Form->input('email');
                        echo $this->Form->input('countries_id');
                        echo $this->Form->input('mobile_phone');
                        echo $this->Form->input('home_phone');
                    ?>
                </div><!--./span4-->
                <div class="span4">
                    <?php
                        echo $this->Form->input('address', array('cols' => 50, 'rows' => 5));
                        echo $this->Form->input('picture', array('type' => 'file'));
                        echo $this->Form->input('recruitment_status', array('label' => __('Status'),'options'=>array('1'=>__('Call for Interview'),'2'=>__('Rejected'),'3'=>__('Pending for Upcoming Oportunities'))));
                    ?>
                </div><!--./span4-->
            </div><!--./row-->
        </div>
        <div class="tab-pane" id="extra">
            <?php
                echo $this->Form->input('Education.0.education_content');
                echo $this->Form->input('Experience.0.experience_content');
                //echo $this->Form->input('Attachment.attachment_route', array('type' => 'file', 'multiple'));
                echo $this->Form->input('other_information');
            ?>
        </div>
    </div>
</fieldset>
<?php 
 $options = array(
'value' => __('Save!'),
'class' => 'btn btn-inverse'
 );
?>  
<div class="paginator-footer"> <?php echo $this->Form->end($options);?> </div>
</div>

but something is wrong there because the associated data never is saved and can’t find what is wrong? Can any help me?

  • 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-30T13:21:46+00:00Added an answer on May 30, 2026 at 1:21 pm

    Make sure your relations are correctly created in the models and use saveAll instead of saveAssociated, as the saveAssociated can’t handle saving multiple entries at one time. What saveAll does is basically combining saveMany and saveAssociated into one single save method.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have thousands of HTML files to process using Groovy/Java and I need to
I have some data like this: 1 2 3 4 5 9 2 6
I'm making a simple page using Google Maps API 3. My first. One marker

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.