tags:

views:

32

answers:

1

Hi, I am using a custom php frame work . i use smarty template engine . i start create a form within the controller file and i introduce a form element in .tpl file using html_checkbox . But this element cannot be found when i submit the form . how do i make the .tpl content part of the form .

+1  A: 

When you create checkboxes using smarty's {html_checkboxes}, the name attribute in the smarty function will be used to as the name for the checkboxes.

For example, if your smarty call is:

{html_checkboxes name='states' options=$states}

The resulting checkboxes will have the name states[] which, when submitted, will be placed into a single PHP array which can be looped over to determine which states were selected:

foreach ($_POST['states'] as $state) {

}

Two things to keep in mind: it is up to you to wrap the checkboxes in form tags. Also if no boxes are checked, they will not be submitted in the form post data. This is a quirk of HTML and has nothing to do with smarty.

webbiedave