|
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_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 |
|
20 */ |
|
21 |
|
22 /** Zend_Form_Element_Xhtml */ |
|
23 require_once 'Zend/Form/Element/Xhtml.php'; |
|
24 |
|
25 /** |
|
26 * Submit form element |
|
27 * |
|
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: Submit.php 22328 2010-05-30 15:09:06Z bittarman $ |
|
34 */ |
|
35 class Zend_Form_Element_Submit extends Zend_Form_Element_Xhtml |
|
36 { |
|
37 /** |
|
38 * Default view helper to use |
|
39 * @var string |
|
40 */ |
|
41 public $helper = 'formSubmit'; |
|
42 |
|
43 /** |
|
44 * Constructor |
|
45 * |
|
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 |
|
49 */ |
|
50 public function __construct($spec, $options = null) |
|
51 { |
|
52 if (is_string($spec) && ((null !== $options) && is_string($options))) { |
|
53 $options = array('label' => $options); |
|
54 } |
|
55 |
|
56 if (!isset($options['ignore'])) { |
|
57 $options['ignore'] = true; |
|
58 } |
|
59 |
|
60 parent::__construct($spec, $options); |
|
61 } |
|
62 |
|
63 /** |
|
64 * Return label |
|
65 * |
|
66 * If no label is present, returns the currently set name. |
|
67 * |
|
68 * If a translator is present, returns the translated label. |
|
69 * |
|
70 * @return string |
|
71 */ |
|
72 public function getLabel() |
|
73 { |
|
74 $value = parent::getLabel(); |
|
75 |
|
76 if (null === $value) { |
|
77 $value = $this->getName(); |
|
78 } |
|
79 |
|
80 if (null !== ($translator = $this->getTranslator())) { |
|
81 return $translator->translate($value); |
|
82 } |
|
83 |
|
84 return $value; |
|
85 } |
|
86 |
|
87 /** |
|
88 * Has this submit button been selected? |
|
89 * |
|
90 * @return bool |
|
91 */ |
|
92 public function isChecked() |
|
93 { |
|
94 $value = $this->getValue(); |
|
95 |
|
96 if (empty($value)) { |
|
97 return false; |
|
98 } |
|
99 if ($value != $this->getLabel()) { |
|
100 return false; |
|
101 } |
|
102 |
|
103 return true; |
|
104 } |
|
105 |
|
106 /** |
|
107 * Default decorators |
|
108 * |
|
109 * Uses only 'Submit' and 'DtDdWrapper' decorators by default. |
|
110 * |
|
111 * @return void |
|
112 */ |
|
113 public function loadDefaultDecorators() |
|
114 { |
|
115 if ($this->loadDefaultDecoratorsIsDisabled()) { |
|
116 return $this; |
|
117 } |
|
118 |
|
119 $decorators = $this->getDecorators(); |
|
120 if (empty($decorators)) { |
|
121 $this->addDecorator('Tooltip') |
|
122 ->addDecorator('ViewHelper') |
|
123 ->addDecorator('DtDdWrapper'); |
|
124 } |
|
125 return $this; |
|
126 } |
|
127 } |