我们使用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}
请帮助解决问题。感谢。
答案 0 :(得分:1)
我认为应该是
{if isset($smarty.post) && isset($smarty.post.cname)}
但为了简洁起见,这应该有效
{if isset($smarty.post.cname)}{$smarty.post.cname}{elseif $editdetails.product_name}{$editdetails.product_name}{/if}
答案 1 :(得分:0)
而不是{$smarty.post.cname}
,您的变量实际上是{$post.cname}
吗?你其他{$editdetails}
似乎暗示了这一点。
这假设$smarty
是PHP Smarty对象变量,而不是模板变量。