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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:52:32+00:00 2026-05-30T08:52:32+00:00

I have the database like this +——————+ | Invoices | +——————+ | id |

  • 0

I have the database like this

+------------------+
|     Invoices     |
+------------------+
| id               |
| customer_id (Fk) |
| description      |
+------------------+

+------------------+
|    Customers     |
+------------------+
| id               |
| firstname        |
| lastname         |
| description      |
+------------------+

So as per my requirment I made multimodel.In that multimodel Customers model is loaded in Invoices model.Now the actionCreate() of invoice controller is like this

public function actionCreate()
  {
    $model=new Invoices;
    $customers = new Customers;

    // Uncomment the following line if AJAX validation is needed
    // $this->performAjaxValidation($model);
    if (isset($_POST['Invoices'],$_POST['Customers']))
    {
      $model->attributes = $_POST['Invoices'];
      $customers->attributes = $_POST['Customers'];
      $valid = $model->validate();
      $valid = $customers->validate();
      if($valid)
      {
        $customers->save(false);
        $model->customer_id = $customers->getPrimaryKey();
        $model->save(false);
         $this->redirect(array('view','id'=>$model->id));
      }
    }
    $this->render('create',array(
      'model'=>$model,
      'customers' => $customers,
    ));
  }

The actionView() is looking like this

  public function actionView($id)
  {
    $this->render('view',array(
      'model'=>$this->loadModel($id),
      'customers'=>Invoices::model()->findByAttributes(array('id'=>$_GET['id']))->customer_id,
      ));
  }

Now when I rendered the form with renderpartial and changed my code in View file like this

 <?php $this->widget('zii.widgets.CDetailView', array(
  'data'=>$model,
  'attributes'=>array(
   'id',
   'customer_id',
    array(
      'label' => 'Firstname',
      'value' => $customers->firstname,
    ),
    array(
      'label' => 'Lastname',
      'value' => $customers->lastname,
    ),
    array(
      'label' => 'description',
      'value' => $customers->description,
    ),
  ),
)); ?>

It showed an error like this Trying to get property of non-object in line ‘value’ => $customers->firstname,
So can someone tell me where the wrong part?Any help and suggestions are welcome.

  • 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-30T08:52:33+00:00Added an answer on May 30, 2026 at 8:52 am

    i think problem in follow code:

    public function actionView($id)
      {
        $this->render('view',array(
          'model'=>$this->loadModel($id),
          'customers'=>Invoices::model()->findByAttributes(array('id'=>$_GET['id']))->customer_id,
          ));
      }
    

    Try this code:

    public function actionView($id)
      {
        $model = $this->loadModel($id);
        $this->render('view',array(
          'model'=>$model,
          'customers'=>Customers::model()->findByAttributes(array('id'=>$model->customer_id)),
          ));
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the database something like this == Invoices == id customer_id == Customers
I have the database just like this ==== Invoices ==== id customer_id description ====
I have strings in a database like this: firstname.lastname@email.com/IMCLientName And I only need the
i have database table like this +-------+--------------+----------+ | id | ip | date |
Suppose I have a database like this: This is set up to give role-wise
I have a database that look like this: [Invoice] -PK:ID -... [InvoiceDetail] -PK:ID -FK:Invoice_ID
I have a table in my postgresql 8.4 database like this: id(serial), event_type_id(id, foreign
I have a mysql database that looks like this: |id | city | created
I have a database application in which a group is modeled like this: TABLE
I have a database full of text fields that look like this: (paragraph of

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.