Yii Framework Forum: Modify content in CGridView ? - Yii Framework Forum

Jump to content

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

Modify content in CGridView ? Rate Topic: -----

#1 User is offline   mech7 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 220
  • Joined: 26-March 09

Posted 12 May 2010 - 06:23 AM

Is there anyway to make it cleaner and not let it use eval?

<?php
$this->widget('zii.widgets.grid.CGridView', array(
	'dataProvider'=> $dataProvider,
	'columns'=>array(
		'id',
		'title',
		'directory',
		'created',

        array(
            'name' => 'description',
            'value' => 'CString::truncate($data->description)',
        ),
		array(
			'class'=>'CButtonColumn',
		),
	),
)); ?>


What is going to happend where there is some php code in description :s
Is there any benefit over just using a foreach loop which makes the code much more readable?
0

#2 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 12 May 2010 - 10:37 AM

View Postmech7, on 12 May 2010 - 06:23 AM, said:

What is going to happend where there is some php code in description :s


Nothing. Not $data->description will get eval'ed but only the code you wrote that uses this variable.
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