1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (https://nette.org)
5: * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6: */
7:
8: namespace Nette\Forms\Controls;
9:
10: use Nette;
11:
12:
13: /**
14: * Push button control with no default behavior.
15: */
16: class Button extends BaseControl
17: {
18:
19: /**
20: * @param string caption
21: */
22: public function __construct($caption = NULL)
23: {
24: parent::__construct($caption);
25: $this->control->type = 'button';
26: }
27:
28:
29: /**
30: * Is button pressed?
31: * @return bool
32: */
33: public function isFilled()
34: {
35: $value = $this->getValue();
36: return $value !== NULL && $value !== array();
37: }
38:
39:
40: /**
41: * Bypasses label generation.
42: * @return void
43: */
44: public function getLabel($caption = NULL)
45: {
46: return NULL;
47: }
48:
49:
50: /**
51: * Generates control's HTML element.
52: * @param string
53: * @return Nette\Utils\Html
54: */
55: public function getControl($caption = NULL)
56: {
57: $this->setOption('rendered', TRUE);
58: $el = clone $this->control;
59: return $el->addAttributes(array(
60: 'name' => $this->getHtmlName(),
61: 'disabled' => $this->isDisabled(),
62: 'value' => $this->translate($caption === NULL ? $this->caption : $caption),
63: ));
64: }
65:
66: }
67: