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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:55:00+00:00 2026-06-17T20:55:00+00:00

I need to know how to call relationship in listData() , For Example in

  • 0

I need to know how to call relationship in listData() ,

For Example in normal way we can call it like :

$model->section->section_name ;

in my code i just print value as number but I need to print string value from courses table .

public function coursesList($section_id) {


        $data=Msection::model()->findAll('section_id=:section_id', 
                array(':section_id'=>(int)$section_id));


        return CHtml::listData($data,'course_id','course_id');
 //// can i call it like : ///listData($data,'course_id->course->course_name','course_id');
        }

Can I call it like:

listData($data,'course_id->course->course_name','course_id');

How To fix that ?

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-06-17T20:55:02+00:00Added an answer on June 17, 2026 at 8:55 pm

    If you are using php 5.3 or more you could call an anonymous function in your ListData where the paramater is the model that the list is working on at this time:

    CHtml::listData($data,'id',function($course) {
        return CHtml::encode($course->course_name);
    });
    

    Source: Yii documentation

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

Sidebar

Related Questions

i need to know the way for call a function in jsp? in my
I just need to know if I want to call my copyconstuctor from pImpl
I need to know if it is possible to call a control and also
does anybody know how to call C++ functions or methods via JavaScript. Need scripting
I need to know whether I should re-call my helper redirectIfNotLoggedIn() inside ajaxFunction, since
i need to know is it possible to call json webservices from background, when
I want to know if there is way to call javascript from java on
I need to know if it's possible to call the Click of a button
I need to know what I am doing wrong because I cannot call the
This is one of those I-don't-know-what-to-call-it so I can't Google it questions. I s

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.