web/lib/Zend/View/Helper/FormCheckbox.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    13  * to license@zend.com so we can send you a copy immediately.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_View
    16  * @package    Zend_View
    17  * @subpackage Helper
    17  * @subpackage Helper
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  * @version    $Id: FormCheckbox.php 20096 2010-01-06 02:05:09Z bkarwin $
    20  * @version    $Id: FormCheckbox.php 24825 2012-05-29 20:42:55Z rob $
    21  */
    21  */
    22 
    22 
    23 
    23 
    24 /**
    24 /**
    25  * Abstract class for extension
    25  * Abstract class for extension
    31  * Helper to generate a "checkbox" element
    31  * Helper to generate a "checkbox" element
    32  *
    32  *
    33  * @category   Zend
    33  * @category   Zend
    34  * @package    Zend_View
    34  * @package    Zend_View
    35  * @subpackage Helper
    35  * @subpackage Helper
    36  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    36  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    37  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    37  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    38  */
    38  */
    39 class Zend_View_Helper_FormCheckbox extends Zend_View_Helper_FormElement
    39 class Zend_View_Helper_FormCheckbox extends Zend_View_Helper_FormElement
    40 {
    40 {
    41     /**
    41     /**
    79         $disabled = '';
    79         $disabled = '';
    80         if ($disable) {
    80         if ($disable) {
    81             $disabled = ' disabled="disabled"';
    81             $disabled = ' disabled="disabled"';
    82         }
    82         }
    83 
    83 
    84         // XHTML or HTML end tag?
    84         // build the element
    85         $endTag = ' />';
    85         $xhtml = '';
    86         if (($this->view instanceof Zend_View_Abstract) && !$this->view->doctype()->isXhtml()) {
    86         if ((!$disable && !strstr($name, '[]'))
    87             $endTag= '>';
    87             && (empty($attribs['disableHidden']) || !$attribs['disableHidden'])
       
    88         ) {
       
    89             $xhtml = $this->_hidden($name, $checkedOptions['uncheckedValue']);
    88         }
    90         }
    89 
    91 
    90         // build the element
    92         if (array_key_exists('disableHidden', $attribs)) {
    91         $xhtml = '';
    93             unset($attribs['disableHidden']);
    92         if (!$disable && !strstr($name, '[]')) {
       
    93             $xhtml = $this->_hidden($name, $checkedOptions['uncheckedValue']);
       
    94         }
    94         }
       
    95 
    95         $xhtml .= '<input type="checkbox"'
    96         $xhtml .= '<input type="checkbox"'
    96                 . ' name="' . $this->view->escape($name) . '"'
    97                 . ' name="' . $this->view->escape($name) . '"'
    97                 . ' id="' . $this->view->escape($id) . '"'
    98                 . ' id="' . $this->view->escape($id) . '"'
    98                 . ' value="' . $this->view->escape($checkedOptions['checkedValue']) . '"'
    99                 . ' value="' . $this->view->escape($checkedOptions['checkedValue']) . '"'
    99                 . $checkedOptions['checkedString']
   100                 . $checkedOptions['checkedString']
   100                 . $disabled
   101                 . $disabled
   101                 . $this->_htmlAttribs($attribs)
   102                 . $this->_htmlAttribs($attribs)
   102                 . $endTag;
   103                 . $this->getClosingBracket();
   103 
   104 
   104         return $xhtml;
   105         return $xhtml;
   105     }
   106     }
   106 
   107 
   107     /**
   108     /**