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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:33:44+00:00 2026-06-11T00:33:44+00:00

In Yii, the following doesn’t work (the relation array remains empty) and doesn’t return

  • 0

In Yii, the following doesn’t work (the relation array remains empty) and doesn’t return an error:

foreach ($data as $k => $relatedModelData){
    //construct the related model from the data passed in
    ...
    $model->arrayOfRelatedModels[] = $relatedModel;
}

Instead, I have to do this:

foreach ($data as $k => $relatedModelData){
    //construct the related model from the data passed in
    ...
    $tempArray[] = $relatedModel;
}

$model->arrayOfRelatedModels = $tempArray;

I am wondering why this is the case, or whether I have got something slightly wrong in the first example?

  • 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-11T00:33:46+00:00Added an answer on June 11, 2026 at 12:33 am

    @o_nix is right, you should be getting the:

    Indirect modification of overloaded property error. It’s something i’ve come across a lot recently.

    It means that Yii is returning you a magic attribute via the __get function, the object doesn’t really exist on the class, and when you set this object it goes through the magic __set function. This means if you try and change something inside the object itself (inner array values for example) it has no idea what to do with them and so it throws up that notice and leaves it alone.

    To get round this you did the right thing, modify a new local variable and set the whole object to this once you’re done.

    P.S
    You might have your PHP configuration set to hide notices, which is why it’s silent.

    Hope that clears it up

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

Sidebar

Related Questions

Situation: My current links are generated by the following yii methods: <?php echo CHtml::link(CHtml::encode($data->name),
When I upload files in Yii using the following code it generates an error.
I'm using Yii's CMenu to generate menu in the following way: $this->widget('zii.widgets.CMenu', array( 'items'=>$this->mainMenu,
I have some forms in Yii using the following to get lists of data
I have started working on yii framework and I am following the yii blog
I had following cgridview in Yii application, I want to change date format in
By taking into consideration the following code snipped: if('<?= Yii::app()->controller->action->id?>' == 'create'){ $(#Event_name).focusout(function(){ $.ajax({
I am in the process of learning the Yii Framework. I have been following
My Yii code not showing error summery before save movie in database.. what's the
Given the following UPDATE query in my controller $connection = yii::app()->db; $sql = UPDATE

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.