View previous topic :: View next topic |
Author |
Message |
Scott Smarty Rookie
Joined: 18 Apr 2003 Posts: 10 Location: Sarasota, FL
|
Posted: Sat May 03, 2003 5:03 am Post subject: How? $smarty.post.value_$smarty.section.role.iteration |
|
|
I'm trying to default a checkbox to the previously posted
value of the same form (which is shown again in case of error).
Code: |
{ section name=role loop=$role_list }
<input type="checkbox" value="1" name="contact_role_{$smarty.section.role.iteration}"
{* WHAT IS USED TO MAKE THIS WORK HERE.... ???? *}
{ if 1 == $smarty.post.contact_role_$smarty.section.role.iteration }
checked
{ /if }
> {* close input checkbox *}
{/section}
|
I thought backslashes would help, but I get an error:
$smarty.post.contact_role_`$smarty.section.role.iteration`
How can I use iteration to access a dynamic POST value? |
|
Back to top |
|
andre Smarty Pro
Joined: 23 Apr 2003 Posts: 164 Location: Karlsruhe, Germany
|
Posted: Sat May 03, 2003 9:15 am Post subject: |
|
|
Replace
Code: | { if 1 == $smarty.post.contact_role_$smarty.section.role.iteration }
checked
{ /if }
|
with
Code: | {assign var="temp" value="contact_role_`$smarty.section.role.iteration`"}
{if 1 == $smarty.post.$temp}
checked
{/if}
|
This is the trick |
|
Back to top |
|
Scott Smarty Rookie
Joined: 18 Apr 2003 Posts: 10 Location: Sarasota, FL
|
Posted: Sat May 03, 2003 11:19 am Post subject: |
|
|
Thanks for the reply, but this doesn't seem to work for me.
Code: |
{assign var="temp" value="contact_role_`$smarty.section.role.iteration`"}
{if 1 == $smarty.post.$temp}
checked
{/if}
> {* end of input *}
temp={$temp}
|
I see:
temp=contact_role_`1`
The slashes are still part of the string.
I'm using Smarty v2.5.0 |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
|
Back to top |
|
Scott Smarty Rookie
Joined: 18 Apr 2003 Posts: 10 Location: Sarasota, FL
|
Posted: Sat May 03, 2003 2:39 pm Post subject: This works great! |
|
|
This does work well!
My test instance was still at version 2.4.2 -- once I upgraded to 2.5.0 it works.
thank you! |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sat May 03, 2003 2:53 pm Post subject: Re: This works great! |
|
|
Scott wrote: | My test instance was still at version 2.4.2 -- once I upgraded to 2.5.0 it works.
|
I really should have said that backticks require 2.5.0+. Especially since I thought something was up when you were getting `'s in your output.
I think we should encourage people to add the results of echo $smarty->_version; to their posts |
|
Back to top |
|
Scott Smarty Rookie
Joined: 18 Apr 2003 Posts: 10 Location: Sarasota, FL
|
Posted: Tue May 06, 2003 12:39 pm Post subject: Re: This works great! |
|
|
boots wrote: |
I really should have said that backticks require 2.5.0+. Especially since I thought something was up when you were getting `'s in your output.
I think we should encourage people to add the results of echo $smarty->_version; to their posts |
Yes, I agree comletely. This may have saved me time searching for the simple answer of "upgrade to 2.5.0".
I also had several other areas that "broke" with using 2.5.0, such as tests for file existence:
Code: |
{ if file_exists("$form.file1") }
|
is now
Code: |
{ if file_exists("`$form.file1`") }
|
|
|
Back to top |
|
|