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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:07:30+00:00 2026-06-15T20:07:30+00:00

I have the following table: CREATE TABLE place ( id int8 NOT NULL DEFAULT

  • 0

I have the following table:

CREATE TABLE "place" (
    "id" int8 NOT NULL DEFAULT nextval('place_id_seq'::regclass),
    "name" varchar(128) NOT NULL,
    "parent" int8,
    "description" varchar(100)
)
WITH (OIDS=FALSE);

(It’s PostgreSQL but this shouldn’t be relevant here)

I created the CRUD through giix and changed a bit the relations to match my needs. So I ended up with:

public function relations() {
    return array(
        'parent0' => array(self::BELONGS_TO, 'Places', 'parent'),
        'places' => array(self::HAS_MANY, 'Places', 'parent'),
    );
}

The goal here is that a place can belong to another place and have multiple children places.

My problem is that I need to change the admin action to match the following grid:
Print manipulated by the inspector to reflect the desired behaviour

Print manipulated by the inspector to reflect the desired behaviour

So my problem is to get the list of all the children objects and display it as a list of links. I tried change the respective admin.php view file for:

$this->widget('zii.widgets.grid.CGridView', array(
    'id' => 'places-grid',
    'dataProvider' => new CActiveDataProvider('Places', array('id'=>$model->places)),
    'filter' => $model,
    'columns' => array(
        array(
                'name'=>'parent',
                'value'=>'GxHtml::valueEx($data->parent0)',
                'filter'=>GxHtml::listDataEx(Places::model()->findAllAttributes(null, true)),
                ),
        'name',
        'places',
        array(
            'class' => 'CButtonColumn',
        ),
    ),
));

But this, as expected, throughs an error:

htmlspecialchars() expects parameter 1 to be string, array given

Also I don’t know this would even work with the built in avanced search.

Could anyone kindly point me into the correct direction here?

  • 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-15T20:07:31+00:00Added an answer on June 15, 2026 at 8:07 pm

    After much search I found a way to solve my problem. Not sure if it’s the best way but it works nicely:

    $this->widget('zii.widgets.grid.CGridView', array(
        'id' => 'places-grid',
        'dataProvider' => new CActiveDataProvider('Places', array('id'=>$model->places)),
        'filter' => $model,
        'columns' => array(
            array(
                    'name'=>'parent',
                    'value'=>'GxHtml::valueEx($data->parent0)',
                    'filter'=>GxHtml::listDataEx(Places::model()->findAllAttributes(null, true)),
                    ),
            'name',
            array(
            'header'=>'Children',
            'type'=>'html',
                    'value'=> function($data) {
                        $placesLinks = array();
                        foreach ($data->places as $place) {
                            $placesLinks[] = GxHtml::link(GxHtml::encode(GxHtml::valueEx($place, 'name')), array('places/view', 'id' => GxActiveRecord::extractPkValue($place, true)));
                        }
                        return implode(', ', $placesLinks);
                    }
            ),
            array(
                'class' => 'CButtonColumn',
            ),
        ),
    ));
    

    This uses Giix. If you don’t use that then you’ll have to change the link generation accordingly.

    Cheers

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

Sidebar

Related Questions

I have the following table CREATE TABLE `prod_prices` ( `id` varchar(32) COLLATE utf8_unicode_ci NOT
I have the following table: CREATE TABLE [dbo].[Data] ( [Id] UNIQUEIDENTIFIER NOT NULL, [Data]
I have the following table: CREATE TABLE TEST(ID TINYINT NULL, COL1 CHAR(1)) INSERT INTO
I have the following table: CREATE TABLE IF NOT EXISTS `customer_list` ( `id` INT
I have the following table: $sql = CREATE TABLE received_queries ( sender_screen_name varchar(50), text
I have the table tblCollectionGameList CREATE TABLE dbo.tblCollectionGameList ( ListID smallint IDENTITY(0,1) NOT NULL,
Having a following table: CREATE TABLE `foo`( `year` INT NOT NULL, `month` INT NOT
I have the following database table created thus: CREATE TABLE AUCTIONS ( ARTICLE_NO VARCHAR(20),
I have the following table: create table ARDebitDetail(ID_ARDebitDetail int identity, ID_Hearing int, ID_AdvancedRatePlan int)
Let's say we have the following table: CREATE TABLE T ( ID INT, String1

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.