PluginProbe
Packeta / 1.6.0
Packeta v1.6.0
2.3.2 2.3.1 trunk 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 All 56 releases
packeta / deps / nette / forms / src / Forms / Controls / Button.php

Button.php in Packeta 1.6.0, at deps/nette/forms/src/Forms/Controls/Button.php

51 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 declare (strict_types=1);
8 namespace Packetery\Nette\Forms\Controls;
9
10 use Packetery\Nette;
11 /**
12 * Push button control with no default behavior.
13 */
14 class Button extends BaseControl
15 {
16 /**
17 * @param string|object $caption
18 */
19 public function __construct($caption = null)
20 {
21 parent::__construct($caption);
22 $this->control->type = 'button';
23 $this->setOption('type', 'button');
24 }
25 /**
26 * Is button pressed?
27 */
28 public function isFilled() : bool
29 {
30 $value = $this->getValue();
31 return $value !== null && $value !== [];
32 }
33 /**
34 * Bypasses label generation.
35 */
36 public function getLabel($caption = null)
37 {
38 return null;
39 }
40 /**
41 * Generates control's HTML element.
42 * @param string|object $caption
43 */
44 public function getControl($caption = null) : \Packetery\Nette\Utils\Html
45 {
46 $this->setOption('rendered', \true);
47 $el = clone $this->control;
48 return $el->addAttributes(['name' => $this->getHtmlName(), 'disabled' => $this->isDisabled(), 'value' => $this->translate($caption ?? $this->getCaption())]);
49 }
50 }
51