【发布时间】:2015-03-16 19:46:05
【问题描述】:
我有以下 smarty 模板:
<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的PHP代码:
$this->smartyci->assign('validation_errors', $error);
所以我现在的问题是,$validation_errors 只有在我将 smarty 设置为调试模式时才会显示在模板中:
<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} 放入模板时才会显示该变量。顺便说一句,任何其他变量都可以正常工作。
【问题讨论】:
-
$this->smartyci->assign('validation_errors', $error); - $this-smartyci 有错吗???
-
没有 $this->smartyci 没问题 :)
标签: php codeigniter debugging smarty