New array indexing problem
| From: | Mirko Buffoni | Date: | Wed, 02 May 2001 10:48:26 +0000 |
| Subject: | New array indexing problem | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-655@lists.php.net to get a copy of this message | ||
Other problem: with version 1.3.2, this template worked fine
{section name=idx loop=$PersonalData}
{if $idx.index/PersonalData.Mandatory == "yes"}
{if $idx.index/PersonalData.FieldType == "radio"}
{include file=form_check_radio.tpl base=#maintest_form_jsbase#
field=$idx.index/PersonalData.FieldName
value=$idx.index/PersonalData.FieldValue
msg="$CheckFieldRadio: "}
{else}
{include file=form_check_text.tpl base=#maintest_form_jsbase#
field=$idx.index/PersonalData.FieldName
value=$idx.index/PersonalData.FieldValue
msg="$CheckFieldText: "}
{/if}
{/if}
{/section}
Now (1.4.0)
{section name=idx loop=$PersonalData}
{if $PersonalData[idx].Mandatory == "yes"}
{if $PersonalData[idx].FieldType == "radio"}
{include file=form_check_radio.tpl base=#maintest_form_jsbase#
field=$PersonalData[idx].FieldName
value=$PersonalData[idx].FieldValue
msg="$CheckFieldRadio: "}
{else}
{include file=form_check_text.tpl base=#maintest_form_jsbase#
field=$PersonalData[idx].FieldName
value=$PersonalData[idx].FieldValue
msg="$CheckFieldText: "}
{/if}
{/if}
{/section}
In the form*.tpl templates, field, and value are empty.
Notice, that $PersonalData[idx].FieldName or FieldValue alone, are correctly
evaluated. Also, the {if $PersonalData[idx].FieldType ...} is correctly
evaluated,
thus I presume the new indexing system is not working correctly with
{include},
or I'm doing a big mistake! PersonalData array is defined this way:
$tpl->assign( "PersonalData",
array( 0 => array( "FieldName" => "Name",
"FieldValue" => "Real Name",
"FieldType" => "text",
"Mandatory" => "yes"
),
1 => array( "FieldName" => "Duty",
"FieldValue" => "Req. Duty",
"FieldType" => "text",
"Mandatory" => "yes"
),
...
)
)
Thanks a lot for any help
Mirko Buffoni