Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

array and checkboxes

 
Post new topic   Reply to topic    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
ricklach
Smarty Regular


Joined: 27 Aug 2004
Posts: 39

PostPosted: Tue Jan 25, 2005 12:14 am    Post subject: array and checkboxes Reply with quote

I have a $result array(associative) that is always a single row with a number and a series of "y" or "n" in the colums. How do I pass that array to a template - is it as simple as $smarty->assign("result", $result) and in the template how do I get at the values (eg. {$result.nameofcolum}???) so that I can assign them to checkboxes so that "Y" = checked.

Rick
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Tue Jan 25, 2005 12:42 am    Post subject: Reply with quote

Yes, you can simply assign the array to Smarty as you suggest. As long as your array is acceptable to html_checkboxes. your life should be easy. It sounds like the following would work:

Code:
{foreach from=$result item=checkboxes key=group}
     {$group} : {html_checkboxes options=$checkboxes}
{/foreach}
Back to top
View user's profile Send private message
ricklach
Smarty Regular


Joined: 27 Aug 2004
Posts: 39

PostPosted: Tue Jan 25, 2005 1:16 am    Post subject: Reply with quote

Boots,

Thanks for that. I learned something new again today.

Rick
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Add-ons All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP