web/lib/Zend/View/Helper/FormSubmit.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     1 <?php
       
     2 /**
       
     3  * Zend Framework
       
     4  *
       
     5  * LICENSE
       
     6  *
       
     7  * This source file is subject to the new BSD license that is bundled
       
     8  * with this package in the file LICENSE.txt.
       
     9  * It is also available through the world-wide-web at this URL:
       
    10  * http://framework.zend.com/license/new-bsd
       
    11  * If you did not receive a copy of the license and are unable to
       
    12  * obtain it through the world-wide-web, please send an email
       
    13  * to license@zend.com so we can send you a copy immediately.
       
    14  *
       
    15  * @category   Zend
       
    16  * @package    Zend_View
       
    17  * @subpackage Helper
       
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    20  * @version    $Id: FormSubmit.php 23403 2010-11-19 19:23:29Z bittarman $
       
    21  */
       
    22 
       
    23 
       
    24 /**
       
    25  * Abstract class for extension
       
    26  */
       
    27 require_once 'Zend/View/Helper/FormElement.php';
       
    28 
       
    29 
       
    30 /**
       
    31  * Helper to generate a "submit" button
       
    32  *
       
    33  * @category   Zend
       
    34  * @package    Zend_View
       
    35  * @subpackage Helper
       
    36  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    37  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    38  */
       
    39 class Zend_View_Helper_FormSubmit extends Zend_View_Helper_FormElement
       
    40 {
       
    41     /**
       
    42      * Generates a 'submit' button.
       
    43      *
       
    44      * @access public
       
    45      *
       
    46      * @param string|array $name If a string, the element name.  If an
       
    47      * array, all other parameters are ignored, and the array elements
       
    48      * are extracted in place of added parameters.
       
    49      *
       
    50      * @param mixed $value The element value.
       
    51      *
       
    52      * @param array $attribs Attributes for the element tag.
       
    53      *
       
    54      * @return string The element XHTML.
       
    55      */
       
    56     public function formSubmit($name, $value = null, $attribs = null)
       
    57     {
       
    58         $info = $this->_getInfo($name, $value, $attribs);
       
    59         extract($info); // name, value, attribs, options, listsep, disable, id
       
    60         // check if disabled
       
    61         $disabled = '';
       
    62         if ($disable) {
       
    63             $disabled = ' disabled="disabled"';
       
    64         }
       
    65 
       
    66         if ($id) {
       
    67             $id = ' id="' . $this->view->escape($id) . '"';
       
    68         }
       
    69 
       
    70         // XHTML or HTML end tag?
       
    71         $endTag = ' />';
       
    72         if (($this->view instanceof Zend_View_Abstract) && !$this->view->doctype()->isXhtml()) {
       
    73             $endTag= '>';
       
    74         }
       
    75 
       
    76         // Render the button.
       
    77         $xhtml = '<input type="submit"'
       
    78                . ' name="' . $this->view->escape($name) . '"'
       
    79                . $id
       
    80                . ' value="' . $this->view->escape($value) . '"'
       
    81                . $disabled
       
    82                . $this->_htmlAttribs($attribs)
       
    83                . $endTag;
       
    84 
       
    85         return $xhtml;
       
    86     }
       
    87 }