Yii Framework Forum: How to display an array data in a single line in CDetailView - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to display an array data in a single line in CDetailView Rate Topic: -----

#1 User is offline   Tsang 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 09-March 12

Posted 14 March 2012 - 09:38 AM

The code:

<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
'tag', // problem here
),
));


If there is an array in the attribute "tag" in this model ($model->tag), how can I display all items in the array?

The attribute 'tag' has an array like this:

$model->tag = array('A', 'B', 'C', 'D');

I want this result:

Tag: A, B, C, D
0

#2 User is offline   mbi 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 608
  • Joined: 08-May 09

Posted 14 March 2012 - 10:03 AM

$this->widget('zii.widgets.CDetailView', array(
  'data'=>$model,
  'attributes'=>array(
    array(
      'name' => 'tag',
      'value' => implode(', ', $model->tag)
    )
  ),
)); 

1

#3 User is offline   Tsang 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 09-March 12

Posted 14 March 2012 - 10:34 AM

View Postmbi, on 14 March 2012 - 10:03 AM, said:

$this->widget('zii.widgets.CDetailView', array(
  'data'=>$model,
  'attributes'=>array(
    array(
      'name' => 'tag',
      'value' => implode(', ', $model->tag)
    )
  ),
)); 


It's work! Thanks!
0

#4 User is offline   FlyngThunderGod 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 29-January 13

Posted 29 January 2013 - 03:45 PM

Thank you for this.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users