Source for file modifier.select.php

Documentation is available at modifier.select.php

  1. <?php
  2. /**
  3.  *  smarty modifier:セレクトボックス用フィルタ
  4.  *
  5.  *  単純なセレクトボックスの場合はsmarty関数"select"を利用することで
  6.  *  タグを省略可能
  7.  *
  8.  *  sample:
  9.  *  <code>
  10.  *  $smarty->assign("form", 1);
  11.  *
  12.  *  <option value="1" {$form|select:"1"}>foo</option>
  13.  *  <option value="2" {$form|select:"2"}>bar</option>
  14.  *  </code>
  15.  *  <code>
  16.  *  <option value="1" selected="selected">foo</option>
  17.  *  <option value="2" >bar</option>
  18.  *  </code>
  19.  *
  20.  *  @param  string  $string セレクトボックスに渡されたフォーム値
  21.  *  @param  string  $value  <option>タグに指定されている値
  22.  *  @return string  $stringが$valueにマッチする場合は"selected"
  23.  */
  24. function smarty_modifier_select($string$value)
  25. {
  26.     //    標準に合わせる
  27.     //    @see http://www.w3.org/TR/html401/interact/forms.html#adef-selected
  28.     //    @see http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd
  29.     //    @see http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd
  30.     //    @see http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-frameset.dtd
  31.     //    @see http://www.w3.org/TR/xhtml-modularization/abstract_modules.html#s_sformsmodule
  32.     if ($string == $value{
  33.         return 'selected="selected"';
  34.     }
  35. }

Documentation generated on Fri, 11 Nov 2011 03:58:44 +0900 by phpDocumentor 1.4.3