Re: [SMARTY-DEV] html_options oversight
| From: | Gerard Samuel | Date: | Sun, 25 Jan 2004 16:42:55 +0000 |
| Subject: | Re: [SMARTY-DEV] html_options oversight | ||
| References: | 1 2 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-2068@lists.php.net to get a copy of this message | ||
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--
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.
Thanks