I am not able to return the property status using the ternary operator
this is my code
<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
<div class="form-group">
<label for="imo_status">STATUS DO IMÓVEL</label>
<div class="form-line">
<select class="form-control" id="imo_status" name="imo_status">
<option value="">Selecione o Status</option>
<option <?= (isset($imo_status) ? $imo_status : set_value('imo_status')) == '1' ? 'selected' : '' ?> value="Ativo">Ativo</option>
<option <?= (isset($imo_status) ? $imo_status : set_value('imo_status')) == '0' ? 'selected' : '' ?> value="Inativo">Inativo</option>
</select>
</div>
</div>
</div>
</div>
Here it should return the option 1 = active
2
Answers
I solved this
I don’t know what PHP version you are using. But the inline
if
with characterx ? y : z
cannot be use twice without bracket. Try this one:Editted
Sorry i read the code wrongly. Actually you need to see whether the method
set_value()
has return any value or not and what value they set to.Try debug with
print_r($imo_status)
andprint_r(set_value('imo_status'))
to see the output.