[ZF-10089] Zend_Log
[zend/radio.git] / library / Zend / Form / Element / Submit.php
blob79c319fd05cbef44c55a131a5e9c13dcf27a81b8
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
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.
15 * @category Zend
16 * @package Zend_Form
17 * @subpackage Element
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
22 /** Zend_Form_Element_Xhtml */
23 require_once 'Zend/Form/Element/Xhtml.php';
25 /**
26 * Submit form element
28 * @category Zend
29 * @package Zend_Form
30 * @subpackage Element
31 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
32 * @license http://framework.zend.com/license/new-bsd New BSD License
33 * @version $Id$
35 class Zend_Form_Element_Submit extends Zend_Form_Element_Xhtml
37 /**
38 * Default view helper to use
39 * @var string
41 public $helper = 'formSubmit';
43 /**
44 * Constructor
46 * @param string|array|Zend_Config $spec Element name or configuration
47 * @param string|array|Zend_Config $options Element value or configuration
48 * @return void
50 public function __construct($spec, $options = null)
52 if (is_string($spec) && ((null !== $options) && is_string($options))) {
53 $options = array('label' => $options);
56 if (!isset($options['ignore'])) {
57 $options['ignore'] = true;
60 parent::__construct($spec, $options);
63 /**
64 * Return label
66 * If no label is present, returns the currently set name.
68 * If a translator is present, returns the translated label.
70 * @return string
72 public function getLabel()
74 $value = parent::getLabel();
76 if (null === $value) {
77 $value = $this->getName();
80 if (null !== ($translator = $this->getTranslator())) {
81 return $translator->translate($value);
84 return $value;
87 /**
88 * Has this submit button been selected?
90 * @return bool
92 public function isChecked()
94 $value = $this->getValue();
96 if (empty($value)) {
97 return false;
99 if ($value != $this->getLabel()) {
100 return false;
103 return true;
107 * Default decorators
109 * Uses only 'Submit' and 'DtDdWrapper' decorators by default.
111 * @return void
113 public function loadDefaultDecorators()
115 if ($this->loadDefaultDecoratorsIsDisabled()) {
116 return $this;
119 $decorators = $this->getDecorators();
120 if (empty($decorators)) {
121 $this->addDecorator('Tooltip')
122 ->addDecorator('ViewHelper')
123 ->addDecorator('DtDdWrapper');
125 return $this;