Reputation: 1216
I have this in my blade:
<select class="form-control" id="item_type" name="item_type">
<option value="physical-goods" <?php if ($product->item_type="physical-goods") echo 'selected=" selected"'; ?>>Physical Goods</option>
<option value="digital-downloads" <?php if ($product->item_type="digital-downloads") echo 'selected=" selected"'; ?>>Digital Downloads</option>
<option value="credits" <?php if ($product->item_type="credits") echo 'selected=" selected"'; ?>>Credits</option>
</select>
now this is what it looks like,
even though Sample Product is a Physical Good, so it should be
What is wrong with my code?
Upvotes: 0
Views: 41
Reputation: 95
Use double equal to instaed of single ==
<?php if ($product->item_type`enter code here`=="digital-downloads") echo 'selected=" selected"'; ?>
<select class="form-control" id="item_type" name="item_type">
<option value="physical-goods" <?php if ($product->item_type=="physical-goods") echo 'selected=" selected"'; ?>>Physical Goods</option>
<option value="digital-downloads" <?php if ($product->item_type=="digital-downloads") echo 'selected=" selected"'; ?>>Digital Downloads</option>
<option value="credits" <?php if ($product->item_type=="credits") echo 'selected=" selected"'; ?>>Credits</option>
</select>
Upvotes: 1