D
D
des1roer2015-05-26 14:35:25
Yii
des1roer, 2015-05-26 14:35:25

Yii 'visible'=> false?

I want to check this
'visible'=> '($data->type == 3)? true: false',
but it doesn't work

$myarray[] = array(
    'class' => 'bootstrap.widgets.TbButtonColumn', //кнопка добавления данных 
    'template' => '{add}',
    'visible'=> dep($data->type),

UPD
, maybe the problem is that these are buttons? he either hides everything or reveals everything. made such a trick
$myarray[] = array(    
    'class' => 'CButtonColumn', //кнопка 
    'template' => '{add}',
    //'visible'=> $data->type == 3,       
    'buttons' => array(
        'add' => array(//the name {reply} must be same
            'label' => '+', // text label of the button
            'url' => '$data->id."|".$data->name."|".$data->type',               
            'click' => 'function(){
                        data=$(this).attr("href").split("|")
                                if (data[2] == 3){
                        $("#myModalHeader").html(data[1]);
                        $("#myModalBody").load("' . $this->createUrl('analizCreate/modalcreate') . '/?id="+data[0]+"");
                        $("#myModal").modal();}
                        return false;
                    }',
            ////Your URL According to your wish
            'options' => array(
                'class' => 'btn btn-small btn-success' ,
            ),
        ),
    ),

Answer the question

In order to leave comments, you need to log in

4 answer(s)
E
entermix, 2015-05-26
@entermix

'visible'=> '($data->type == 3)? true: false',
Why is the ternary operator enclosed in single brackets? What for?

P
Papa, 2015-05-26
Stifflera @PapaStifflera

Remove the ternary operator...
'visible'=> $data->type == 3,

A
alex stephen, 2015-05-26
@berezuev

remove the quotes...
If it still doesn't work, then study with var_dump what $data->type produces

G
George, 2015-05-27
@gogametreveli

Try like this

$myarray[] = array(    
    'class' => 'CButtonColumn', //кнопка 
    'template' => '{add}',
    'buttons' => array(
        'add' => array(//the name {reply} must be same
            'label' => '+', // text label of the button
            'visible'=> '$data->type == 3',
            'url' => '$data->id."|".$data->name."|".$data->type',               
            'click' => 'function(){
                        data=$(this).attr("href").split("|")
                                if (data[2] == 3){
                        $("#myModalHeader").html(data[1]);
                        $("#myModalBody").load("' . $this->createUrl('analizCreate/modalcreate') . '/?id="+data[0]+"");
                        $("#myModal").modal();}
                        return false;
                    }',
            ////Your URL According to your wish
            'options' => array(
                'class' => 'btn btn-small btn-success' ,
            ),
        ),
    ),

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question