Answer the question
In order to leave comments, you need to log in
How in yii2 in view to display data only if it exists?
Hello. I pass an array to the view and show the data in some places from it.
There may be no data in the elements, how then not to show part of the view file?
For example, this code:
<? if (!empty($theuserinvoice['phone'])) { ?>
<span class="labelo">Phone: </span> <?=$theuserinvoice['phone']?> <br/>
<? } ?>
<? if ($theuserinvoice['phone'] != '') { ?>
<span class="labelo">Phone: </span> <?=$theuserinvoice['phone']?> <br/>
<? } ?>
// или
<? if ($theuserinvoice['phone'] != NULL) { ?>
<span class="labelo">Phone: </span> <?=$theuserinvoice['phone']?> <br/>
<? } ?>
Answer the question
In order to leave comments, you need to log in
Nikolai Petyukh hahaha))) your categoricalness is amazing. after all, you don’t know what kind of markup is there, but you express it this way)) and in his case it is quite possible that the element is dynamic, and then Ivan Kondratiev is right))
And in fact, if the element is added dynamically, then the client event is not yet fixed to it. the code
$(document.body).on('click','.responsesimilar', function(){
console.log(this);
});
Do var_dump($theuserinvoice['phone'])
it and see what really lies there, only then you can draw conclusions.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question