Re: [SMARTY-DEV] html_options oversight
| From: | messju mohr | Date: | Sun, 25 Jan 2004 17:26:32 +0000 |
| Subject: | Re: [SMARTY-DEV] html_options oversight | ||
| References: | 1 2 3 4 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-2070@lists.php.net to get a copy of this message | ||
On Sun, Jan 25, 2004 at 06:23:29PM +0100, messju mohr wrote:
> On Sun, Jan 25, 2004 at 11:42:55AM -0500, Gerard Samuel wrote:
> > On Sunday 25 January 2004 10:55 am, messju mohr wrote:
> > > how do you manage to do that? when i pass an empty array to
> > > html_options i get no output at all, not even the <select>-tag.
> > >
> >
> > No you misunderstood me.
> > <?php
> > $foo = array();
> > $smarty->assign('bar', $foo);
> > $smarty->display('foo_bar.tpl');
> > ?>
> >
> > --foo_bar.tpl--
> > <select name="foo">
> > {html_options options=$bar}
> > </select>
> > --foo_bar.tpl--
>
> ah, ok.
>
> {html_options} shouldn't create an empty <option> if no options are
> given, then.
>
> others may use it the following:
>
> <select name="foo">
> <option value="">default</option>
> {html_options options=$bar}
> </select>
>
> and {html_options} can not know here if the context it was called is
> has other options or not.
erm "was called *in*"
> > With the php array $foo being empty, the resulting html is ->
> > <select name="foo">
> > </select>
> >
> > This is when it becomes illegal (X)HTML.
> > For it to become "legal", it would have to be
> > <select name="foo">
> > <option></option>
> > </select>
> >
> > Now I was thinking after I sent the original email, that I could probably
> > force $bar to contain data that would create something like the "legal"
> > example.
> > $foo = array(null => '');
> >
> > I haven't tried that as yet to see what html_options would do in this case.
> > Im hoping that it doesn't produce an empty value for the <option> tag
> > <option value=""></option> as Im not sure if
> > <option value=""></option> is same and equal to
> > <option></option> during the
> > form POST.
> > Im open to ideas if any.
>
> it does create an empty value '<option value=""></option>' but
> i'm
> sure this passes the same value to the browser as '<option></option>'
> would, namely an empty one.
sorry, i meant "the browser passes the same values to the server", of
course.
> > Thanks