Question

I have currently created a CButtonColumn in my CGridView to display several options for related models. Like this

'buttons' => array(
            'publish' => array(
                'label' => 'Publish',
                'visible' => '(isset($data->deutsch))?true:false;',
                'imageUrl' => Yii::app()->request->baseUrl . '/images/publish.png',
                'click' => "function(){
   ...
return false;
}
...
            ),

Where "deutsch" is the name of a HAS_ONE Relation, I basically want to create a visible exception in a way where I check if the record exists firsts, then check a field in that record! so I tried to implement a nested if Statement:

'visible' => 'if(isset($data->deutsch)){if($data->deutsch->in_something==1){true;}false;} ',

But unfortunately it didnt work. Should I just create a function and call it or is there a simpler way to do it? I have been going around this for the last 2 hours....

any help, tips or advices are greatly appreciated :) Thanks for taking the time to read this.

Was it helpful?

Solution

'visible'=>'(isset($data->deutsch) && $data->deutsch->in_something==1)?true:false;'

Should work for you, I've just tested this on a similar dataset on one of my projects.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top