PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, December 30, 2021

[FIXED] How to hide a raw in view.php file using Yii2 Framework

 December 30, 2021     hide, options, raw, yii     No comments   

Issue

I have this raw in my view.php file:

[
              'attribute' => 'Descrizione',
                'format' => 'html',
                'value' => function ( $model ) {
                return nl2br($model->Descrizione);
              },
              'label' => 'Descrizione',
                ],

What I want is to hide the entire field if the value don't contains any character, so if is = "" OR is NULL. So I want to hide the entire field "Descrizione". Which is the option that I have to add in this code? Thank you very much


Solution

Are you using Gridview or DetailView ?

If DetailView, try :

[
  'attribute' => 'Descrizione',
  'label' => 'Descrizione',
  'visible' => !empty($model->Descrizione),
  'format' => 'ntext',
],


Answered By - Timothée Planchais
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing