[英]Smarty $smarty.post it's not working even all reserved variable it's working include .get etc
[英]smarty throwing error on using $smarty.post
我們正在使用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}
請幫忙修復,效果很好。 謝謝。
我認為應該
{if isset($smarty.post) && isset($smarty.post.cname)}
但是為了簡潔起見,這應該有效
{if isset($smarty.post.cname)}{$smarty.post.cname}{elseif $editdetails.product_name}{$editdetails.product_name}{/if}
您的變量實際上叫做{$post.cname}
而不是{$smarty.post.cname}
{$post.cname}
嗎? 您其他的{$editdetails}
似乎暗示了這一點。
假定$smarty
是PHP Smarty對象變量,而不是模板變量。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.