RE: [SMARTY-DEV] Checkbox syntax
| From: | Monte Ohrt | Date: | Mon, 05 May 2003 19:49:23 +0000 |
| Subject: | RE: [SMARTY-DEV] Checkbox syntax | ||
| References: | 1 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-1361@lists.php.net to get a copy of this message | ||
I expects an array. Dump out the content of the form results, see what
it is.
print_r($_REQUEST);
On Mon, 2003-05-05 at 14:42, luis wrote:
> <checkbox name="mychecks[]" value="{$mychecks[foo].name}"
> {if
> in_array($mycheckx[foo].name,$smarty.request.mychecks)}checked="checked"
> {/if} />
>
> Error: wrong datatype for second argument, maybe
> $smarty.request.mychecks is not an array?
>
>
> -----Original Message-----
> From: Monte Ohrt [mailto:monte@ispi.net]
> Sent: Monday, May 05, 2003 4:34 PM
> To: luis
> Cc: 'Smarty Dev'
> Subject: RE: [SMARTY-DEV] Checkbox syntax
>
> If you're not using the {checkboxes} function, maybe use an array
>
> {if in_array($mychecks[foo], $selected_vals)}
>
> On Mon, 2003-05-05 at 14:31, luis wrote:
> > What do you put in the if?
> > {if $smarty.request.mychecks[??]}checked="checked"{/if}
> >
> > -----Original Message-----
> > From: Monte Ohrt [mailto:monte@ispi.net]
> > Sent: Monday, May 05, 2003 4:19 PM
> > To: luis
> > Cc: 'Smarty Dev'
> > Subject: Re: [SMARTY-DEV] Checkbox syntax
> >
> > Use an array instead of separately named checkboxes:
> >
> > <input type="checkbox" name="mychecks[]"
> > value="{$mychecks[foo]}" {if
> > ..}checked="checked"{/if}>
> >
> > On Mon, 2003-05-05 at 14:15, luis wrote:
> > > Let's suposse I have checkboxes inside a section loop so the "name"
> of
> > > each checkbox is:
> > > <input type="checkbox" name="{elements[$foo[ix]]}" />
> > >
> > > I want to preserve checked boxes when processing a form in the
> script
> > ..
> > > Tried something like..
> > >
> > > <input type="checkbox" name="{elements[$foo[ix]]}" {if
> > > $smarty.request.elements[$foo[ix]]}checked="checked"{/if} />
> > >
> > > but it doesn't work.
> > > Which is the best way to do this? Maybe I'm overlooking something
> more
> > > elegant..
> > >
> > > Luis
> > >
> --
> Monte Ohrt <monte@ispi.net>
>
>
> --
> Smarty Development Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--
Monte Ohrt <monte@ispi.net>