Html 在smarty中的select标记内使用if语句的替代方法
我已经使用smarty模板引擎一段时间了,现在我面临着这种情况 为什么这会给我一个错误Html 在smarty中的select标记内使用if语句的替代方法,html,if-statement,smarty,Html,If Statement,Smarty,我已经使用smarty模板引擎一段时间了,现在我面临着这种情况 为什么这会给我一个错误 <select class="m-wrap span8" name="status" required> <option value="" {if $frontuser->status eq ''}selected{/if}>Seleccione</option> <option value="1" {if $frontuser->status
<select class="m-wrap span8" name="status" required>
<option value="" {if $frontuser->status eq ''}selected{/if}>Seleccione</option>
<option value="1" {if $frontuser->status eq '1'}selected{/if}>No Activo</option>
<option value="2" {if $frontuser->status eq '2'}selected{/if}>Activo</option>
</select>
如您所见,我正在从object frontuser调用status属性,我要做的是从数据库中读取状态是否为1、2或空。因此,如果它是这些选项之一,选择标记必须显示它
我以前尝试过这一点,但不是使用对象,而是使用数组,如您所见:
<select class="m-wrap span8 chosen" name="gender" data-with-diselect="1" required>
<option value=" " {if $okInfo['gender'] eq ' '}selected{/if}>Seleccione</option>
<option value="1" {if $okInfo['gender'] eq '1'}selected{/if}>Hombre</option>
<option value="2" {if $okInfo['gender'] eq '2'}selected{/if}>Mujer</option>
</select>
有什么线索吗?谢谢 经过两天的努力,我找到了答案。这很简单--只需添加如下内容:
<option value="2" {if '$frontuser->status' eq ' '}selected{/if}>Seleccione</option>
<option value="1" {if '$frontuser->status' eq '1'}selected{/if}>No Activo</option>
<option value="2" {if '$frontuser->status' eq '2'}selected{/if}>Activo</option>
尝试用单引号表示状态?从语法突出显示中可以看出,在>符号后面有一个简单的问题。我想是的,但是我能做什么呢?