control->type = 'button'; $this->setOption('type', 'button'); } /** * Is button pressed? */ public function isFilled() : bool { $value = $this->getValue(); return $value !== null && $value !== []; } /** * Bypasses label generation. */ public function getLabel($caption = null) { return null; } /** @return static */ public function renderAsButton(bool $state = \true) { $this->control->setName($state ? 'button' : 'input'); return $this; } /** * Generates control's HTML element. * @param string|object $caption */ public function getControl($caption = null) : Html { $this->setOption('rendered', \true); $caption = $this->translate($caption ?? $this->getCaption()); $el = (clone $this->control)->addAttributes(['name' => $this->getHtmlName(), 'disabled' => $this->isDisabled()]); if ($caption instanceof Html || $caption !== null && $el->getName() === 'button') { $el->setName('button')->setText($caption); } else { $el->value = $caption; } return $el; } }