RE: [SMARTY] US states like html_options
| From: | Mark Priatel | Date: | Mon, 03 Nov 2003 03:49:44 +0000 |
| Subject: | RE: [SMARTY] US states like html_options | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-10491@lists.php.net to get a copy of this message | ||
Why not just use html_options and supply it an array containing all the US
states?
Or, if you're looking to encapsulate the country/state information into a
custom plugin, the easiest thing to do is 'extend', or chain into, the
html_options plugin.
// create a new plugin called html_options_states
function smarty_function_html_options_states($params, &$smarty) {
$states = array("CA" => "California",
"NY" => "New York",
// add all your other states as key=>val
);
$params['options'] = $states;
// then call the real html_options plugin
require_once $smarty->_get_plugin_filepath('function','html_options');
return smarty_function_html_options($params,$smarty);
}
The advantage the solution above is that you can use all the same parameters
that html_options would accept, because any parameters you pass to your
function are in turn passed to the html_options plugin.
{html_options_states selected='NY' name='states'}
-mark
------------------------------
Mark Priatel
Iolog Web Communications
http://www.iolog.com
-----Original Message-----
From: Kevin Coyner [mailto:kevin@rustybear.com]
Sent: Sunday, November 02, 2003 9:05 PM
To: smarty-general@lists.php.net
Subject: Re: [SMARTY] US states like html_options
On Sun, Nov 02, 2003 at 08:32:22PM -0500, Kevin Coyner wrote......
> I'm new to Smarty but finding it useful.
>
> Per the docs, I've found and used 'html_options' to great advantage.
Oops. I meant to say html_select_date.
> Is there a similar function that lists all the U.S. States in a <select>
> form?
>
> While I'm asking, how about one for countries as well?
>
> Thanks
> Kevin
--
Kevin Coyner
mailto: kevin@rustybear.com
GnuPG key: 1024D/8CE11941
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php