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