filthy
(Stephane Belanger174)
1
My code:
<?php $this->widget(‘zii.widgets.CDetailView’, array(
'data'=>$model,
'attributes'=>array(
'id',
'ytd_committed_amount',
'ytd_actuals_amount',
'forecast_amount',
array(
'label'=>'Project Authority',
'value'=>(!empty($model->person->first_name.' '.$model->person->last_name)),
? CHtml::encode($model->person->first_name." ".$model->person->last_name) : ''),
getting an error. This works fine:
array(
'label'=>'Type',
'value'=>(!empty($model->projectType->name_en))
? CHtml::encode($model->projectType->name_en) : ''),
But the …first_name.’ '.$model->p… is causing an error.
Am i missing quotes, double quotes, or something else?
dniznick
(Dniznick)
2
Just write a function in your model class.
public function getFullName()
{
return $this->firstName . ' ' . $this->lastName;
}
Call it in the view as $model->fullName.
filthy
(Stephane Belanger174)
3
yes tried that. still getting an error, maybe because it’s late, i am not seeing it.
here is the complete code:
<?php $this->widget(‘zii.widgets.CDetailView’, array(
'data'=>$model,
'attributes'=>array(
'id',
'tenant_id',
'note_text',
'created_date',
'project_id',
array(
'label'=>'Priority?',
'value'=>$model->is_priority ? "Yes" : "No"),
array(
'label'=>'Created By',
'value'=>(!empty($model->person->fullName)
? CHtml::encode($model->person->fullName) : ''),
),
)); ?>
error shoes as: syntax error eof . unexpected at )); ?>
filthy
(Stephane Belanger174)
4
nevermind. missing a parenthesis.
<?php $this->widget(‘zii.widgets.CDetailView’, array(
‘data’=>$model,
‘attributes’=>array(
‘id’,
‘tenant_id’,
‘note_text’,
‘created_date’,
‘project_id’,
array(
‘label’=>‘Priority?’,
‘value’=>$model->is_priority ? “Yes” : “No”),
array(
‘label’=>‘Created By’,
‘value’=>(!empty($model->person->fullName)) <------------------------------------
? CHtml::encode($model->person->fullName) : ‘’),
),
)); ?>