Trying to display a Smarty variable with a hyphen in the key. Nothing I can do to change the fact that it has a hyphen in the key.
For example, a phone number may be stored within the $form array as:
phone-1-1 => Array (9)
name => "phone-1-1"
value => "(555) 555-5555"
type => "text"
frozen => false
required => false
error => null
id => "phone-1-1"
label => "<label for="phone-1-1">Phone Number (..."
html => "<input maxlength="32" size="20" name=..."
Trying to print the smarty variable using:
{$form.phone-1-1.label}
fails because of the hyphens.
Any ideas how I get around that?
The only workaround you can use is:
{assign var="mykey" value="phone-1-1"}
{$form.$mykey.label}
The bult-in Smarty function {assign}
let you create variables directly in the template.
http://www.smarty.net/docs/en/language.function.assign.tpl (for Smarty 3)
http://www.smarty.net/docsv2/en/language.custom.functions.tpl (for Smarty 2)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With