'How can i hide dt if dd got empty value
I need to hide dt if dd got empty value. how can i do that?
<dt class="col-sm-6 text-dark" >Subject</dt>
<dd class="col-sm-6">{{$course_dtl->subject_title }}</dd>
Like i want to hide Subject if subject_title has no value.
Solution 1:[1]
As Brombeer said blade templating has if statements and you can surround the whole block with one:
@if (!empty($course_dtl->subject_title))
<dt class="col-sm-6 text-dark" >Subject</dt>
<dd class="col-sm-6">{{$course_dtl->subject_title }}</dd>
@endif
Solution 2:[2]
If you want to hide only dt then you can do this also
<dt class="col-sm-6 text-dark" style="display: {{ $course_dtl->subject_title ? 'block' : 'none' }}" >Subject</dt>
<dd class="col-sm-6">{{$course_dtl->subject_title }}</dd>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | John Zwarthoed |
Solution 2 | N.S |