Assign value to input fields in bootstrap tabs based on some condition

360 views Asked by At

I am unable assign a value to input fields in bootstrap tabs based on a condition, it works fine in the first tab but not in the second tab. This is what I have tried so far:

 <ul class="nav nav-tabs">
     <li class="active"><a href="#One" data-toggle="tab">First</a></li>
     <li class=""><a href="#Two" data-toggle="tab">Second</a></li> 
</ul>

<div id="tabContent" class="tab-content">
     <div class="tab-pane fade" id="One">
          //Its works fine,and assigns the value to input field.
           <input type="text" value="{{($row->value== 1) ?'test':'')}}" />
     </div>
     <div class="tab-pane fade" id="Two">
          //value is not assigned to input field though condition is true.
            <input type="text" value="{{($row->value== 1) ?'test':'')}}" />
     </div>
</div>
1

There are 1 answers

2
chasepeeler On

You are using twig? If I remember correctly, you only use {{}} for variables: {{myVar}}. For expressions, use {% %}.

{% $row->value == 1 ? 'test':'' %}