我有以下聪明的模板:
<div class="col-md-4 col-sm-4 col-lg-4 col-xs-12 col-md-offset-4 col-lg-offset-4 col-sm-offset-4 login-box">
{$validation_errors}
<p class="heading">Please Log In!</p>
{form url='user/login'}
<div class="form-group">
<label for="Email">Email address</label>
<input type="text" class="form-control" id="Email" placeholder="Enter email" name="email" />
</div>
<div class="form-group">
<label for="Password">Email address</label>
<input type="password" class="form-control" id="Password" placeholder="Enter password" name="password" />
</div>
<button type="submit" class="btn btn-success pull-right">Submit</button>
{form}
</div>
这是分配$validation_errors
:
$this->smartyci->assign('validation_errors', $error);
所以现在我的问题是,如果我将smarty设置为调试模式,那么$validation_errors
仅显示在模板中:
<div class="col-md-4 col-sm-4 col-lg-4 col-xs-12 col-md-offset-4 col-lg-offset-4 col-sm-offset-4 login-box">
{debug}
{$validation_errors}
<p class="heading">Please Log In!</p>
{form url='user/login'}
<div class="form-group">
<label for="Email">Email address</label>
<input type="text" class="form-control" id="Email" placeholder="Enter email" name="email" />
</div>
<div class="form-group">
<label for="Password">Email address</label>
<input type="password" class="form-control" id="Password" placeholder="Enter password" name="password" />
</div>
<button type="submit" class="btn btn-success pull-right">Submit</button>
{form}
</div>
我现在真的知道为什么只在我将{debug}放入模板时才会显示变量。顺便说一下其他任何变量都可以正常工作。
答案 0 :(得分:1)
$ validation_errors变量以某种方式受到智能缓存的影响。 我已经禁用了chaching,现在一切正常。