我们正在使用smarty作为我们的一个表单的模板系统,请检查添加/编辑表单代码...
<form action="{$MAIN_URL}products/add" method="post" class="clearfix">
<input type="text" name="cname" value="{if $smarty.post.cname}{$smarty.post.cname}{elseif $editdetails.product_name}{$editdetails.product_name}{/if}" />它抛出下面的错误...
Undefined variable: post in <b>/root/smarty/libs/sysplugins/smarty_internal_data.php</b> on line 291如果我们删除{if $smarty.post.cname}{$smarty.post.cname},它可以正常工作,请帮助修复。谢谢。
发布于 2011-04-01 05:47:44
我觉得应该是
{if isset($smarty.post) && isset($smarty.post.cname)}但为了简洁起见,这应该是可行的
{if isset($smarty.post.cname)}{$smarty.post.cname}{elseif $editdetails.product_name}{$editdetails.product_name}{/if}发布于 2011-04-01 04:44:21
实际上,您的变量名为{$post.cname}而不是{$smarty.post.cname}吗?你的另一个{$editdetails}似乎暗示了这一点。
这里假设$smarty是PHP Smarty对象变量,而不是模板变量。
https://stackoverflow.com/questions/5506039
复制相似问题