Created
February 12, 2016 01:50
-
-
Save catoidrobo/8319bde9c7cb783c5654 to your computer and use it in GitHub Desktop.
smartyでのプルダウン(セレクトボックス)の表示
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<select name="s_ad_type"> | |
<!-- | |
$pulldown_arr : プルダウンの中身が入ったindex配列 | |
$checked_value : チェック済みにしたい値 | |
--> | |
{foreach key=key item=val from=$pulldown_arr name=pulldown} | |
{if $val == $checked_value} | |
{assign var=checked value="selected"} | |
{else} | |
{assign var=checked value=""} | |
{/if} | |
<option label="{$val}" value="{$val}" {$checked}>{$val}</option> | |
{/foreach} | |
<!-- | |
smartyで準備されたカスタム関数を使えば、上記の処理を簡単にかける | |
--> | |
{html_options values=$s_ad_type output=$pulldown_arr selected=$checked_value} | |
</select> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment