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: * @author David Grudl
17: */
18: class Button extends BaseControl
19: {
20:
21: /**
22: * @param string caption
23: */
24: public function __construct($caption = NULL)
25: {
26: parent::__construct($caption);
27: $this->control->type = 'button';
28: }
29:
30:
31: /**
32: * Is button pressed?
33: * @return bool
34: */
35: public function isFilled()
36: {
37: $value = $this->getValue();
38: return $value !== NULL && $value !== array();
39: }
40:
41:
42: /**
43: * Bypasses label generation.
44: * @return void
45: */
46: public function getLabel($caption = NULL)
47: {
48: return NULL;
49: }
50:
51:
52: /**
53: * Generates control's HTML element.
54: * @param string
55: * @return Nette\Utils\Html
56: */
57: public function getControl($caption = NULL)
58: {
59: $this->setOption('rendered', TRUE);
60: $el = clone $this->control;
61: return $el->addAttributes(array(
62: 'name' => $this->getHtmlName(),
63: 'id' => $this->getHtmlId(),
64: 'disabled' => $this->isDisabled(),
65: 'value' => $this->translate($caption === NULL ? $this->caption : $caption),
66: ));
67: }
68:
69: }
70: