Source for file modifier.checkbox.php

Documentation is available at modifier.checkbox.php

  1. <?php
  2. /**
  3.  *  smarty modifier:チェックボックス用フィルタ
  4.  *
  5.  *  sample:
  6.  *  <code>
  7.  *  <input type="checkbox" name="test" {""|checkbox}>
  8.  *  <input type="checkbox" name="test" {"1"|checkbox}>
  9.  *  </code>
  10.  *  <code>
  11.  *  <input type="checkbox" name="test">
  12.  *  <input type="checkbox" name="test" checked="checked">
  13.  *  </code>
  14.  *
  15.  *  @param  string  $string チェックボックスに渡されたフォーム値(スカラーのみ)
  16.  *  @return string  $stringが空文字列あるいは0, null, false 以外の場合は"checked"
  17.  */
  18. function smarty_modifier_checkbox($string)
  19. {
  20.     if (is_scalar($string&& $string != "" && $string != "0"{
  21.         return 'checked="checked"';
  22.     }
  23. }

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