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

  • Home
  • SEARCH
  • 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 6785931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:11:09+00:00 2026-05-26T17:11:09+00:00

In my project one of the model named types having multiple relation to other

  • 0

In my project one of the model named types having multiple relation to other models the criteria with part is giving below its like

$criteria->with = array(
            'category',
            'subCategory',
            'accountsSupplierPriceDetails' => array(
                'with' => 'serviceLevel'
            )
        );

the relationship goes like

  • types – category – relation(1-1)
  • types – subcategory – relation(1-1)
  • types – accountsSupplierPriceDetails – relation(1-1)
  • accountsSupplierPriceDetails – serviceLevel – relation(1-n)

my problem is how to display the names from each table in a grid. the result of (1-n) should be displayed in a dropdownbox. when i try to access the data from column it shows the error Trying to get property of non-object ($data->accountsSupplierPriceDetails->serviceLevel ->name). can anyone please help me.

Thanks in advance.

  • 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-26T17:11:10+00:00Added an answer on May 26, 2026 at 5:11 pm

    in my view i create a cgridview with 5 rows in which one row data is populated using dropdownlist.

        <div style="width:700px; height:auto;">
            <?php
            $widget = $this->widget('zii.widgets.grid.CGridView', array(
                'id' => 'response-grid',
                'dataProvider' => $pickdataset->pickCategorylistingForMain(),
                'cssFile' => Yii::app()->baseUrl . '/media/css/gridview.css',
                'summaryText' => '',
                'ajaxUpdate' => 'response-grid',
                'enablePagination' => true,
                'pager' => array(
                    'class' => 'LinkPager',
                    'cssFile' => false,
                    'header' => false,
                    'firstPageLabel' => 'First',
                    'prevPageLabel' => 'Previous',
                    'nextPageLabel' => 'Next',
                    'lastPageLabel' => 'Last',
                ),
                'columns' => array(
                    array(
                        'name' => 'id',
                        'header' => '#',
                        'value' => '$this->grid->dataProvider->pagination->currentPage * $this->grid->dataProvider->pagination->pageSize + ($row+1)',
                    ),
                    array(
                        'type' => 'raw',
                        'name' => 'categoryExt',
                        'header' => 'Category',
                    ),
                    array(
                        'type' => 'raw',
                        'header' => 'Sub Category',
                        'value' => '$data->subCategory->name',
                    ),
                    array(
                        'type' => 'raw',
                        'name' => 'locationExt',
                        'header' => 'Location',
                    ),
                    array(
                        'type' => 'raw',
                        'header' => 'Name',
                        'value' => 'CHtml::dropDownList($data->corporate_id."-".$data->category_id."-".$data->sub_category_id."-".$data->location_id,"",popDropBox($data->masterCategoryServiceLevels), array("class" => "listbox"), array("empty" => "Select a Location"))',
                    ),
                    array(
                        'type' => 'raw',
                        'header' => 'Pick',
                        'value' => 'CHtml::image(Yii::app()->baseUrl . "/media/images/edit_icon.png",$data->corporate_id."-".$data->category_id."-".$data->sub_category_id."-".$data->location_id,array("title" => "Select this Combination"))',
                    ),
                ),));
    
            function popDropBox($data)
            {
                $list = array();
                foreach ($data as $row)
                {
                    $list[$row->serviceLevel->id] = $row->serviceLevel->name;
                }
                return $list;
            }
            ?>
    </div>
    

    the relation in model is:

    'masterCategoryServiceLevels' => array(self::HAS_MANY, 'MasterCategoryServiceLevel', 'category_template_id'),
    'corporate' => array(self::BELONGS_TO, 'AccountsCorporate', 'corporate_id'),
    'category' => array(self::BELONGS_TO, 'MasterCategory', 'category_id'),
    'subCategory' => array(self::BELONGS_TO, 'MasterCategory', 'sub_category_id'),
    'location' => array(self::BELONGS_TO, 'MasterLocation', 'location_id'),
    

    the row is

    array(
    'type' => 'raw',
    
    'header' => 'Name',
    
    'value' => 'CHtml::dropDownList($data->corporate_id."-".$data->category_id."-".$data->sub_category_id."-".$data->location_id,"",popDropBox($data->masterCategoryServiceLevels), array("class" => "listbox"), array("empty" => "Select a Location"))',
                        ),
    

    and i use a function to create dropdown data is

    function popDropBox($data)
                {
                    $list = array();
                    foreach ($data as $row)
                    {
                        $list[$row->serviceLevel->id] = $row->serviceLevel->name;
                    }
                    return $list;
                }
    

    please comment if you have any doubt. i am free to share… have a nice day SO friends… wishes and prayers.

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

Sidebar

Related Questions

I have a Project model and it has some text attributes, one is summary.
I'm working on a project with Hibernate and MySQL. In one of my model
I'm working with an external framework (redmine) which has one Project model that has_many
Consider this simple model, where a Project has one ProjectType and, naturally many Projects
D:\zjm_code\basic_project>python manage.py syncdb Error: One or more models did not validate: topics.topic: Accessor for
i have a problem to distributing application with 2 project (one project with sub-project
I have several projects open in an Eclipse workspace. Like so: com.harbl.project.one com.harbl.project.two com.harbl.project.three
Why one project (exe) does not see the namespace of another project (dll) in
I have one project with is developed in Php and javascript. How to open
I have one project which has RIAService with entity framework that is referenced to

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.