should be created with the same warning as in the icon label * * @var bool */ protected $accessible; /** * The id used to identify the auto-submit warning associated with the decorated form element * * @var string */ protected $warningId; /** * Set whether a hidden should be created with the same warning as in the icon label * * @param bool $state * * @return Autosubmit */ public function setAccessible($state = true) { $this->accessible = (bool) $state; return $this; } /** * Return whether a hidden is being created with the same warning as in the icon label * * @return bool */ public function getAccessible() { if ($this->accessible === null) { $this->accessible = $this->getOption('accessible') ?: false; } return $this->accessible; } /** * Return the id used to identify the auto-submit warning associated with the decorated element * * @param mixed $element The element for which to generate a id * * @return string */ public function getWarningId($element = null) { if ($this->warningId === null) { $element = $element ?: $this->getElement(); $this->warningId = 'autosubmit_warning_' . $element->getId(); } return $this->warningId; } /** * Return the current view * * @return View */ protected function getView() { return Icinga::app()->getViewRenderer()->view; } /** * Add a auto-submit icon and submit button encapsulated in noscript-tags to the element * * @param string $content The html rendered so far * * @return string The updated html */ public function render($content = '') { if ($content) { $isForm = $this->getElement() instanceof Form; $warning = $isForm ? t('This page will be automatically updated upon change of any of this form\'s fields') : t('This page will be automatically updated upon change of the value'); $content .= $this->getView()->icon('cw', $warning, array( 'aria-hidden' => $isForm ? 'false' : 'true', 'class' => 'spinner autosubmit-info' )); if (! $isForm && $this->getAccessible()) { $content = '' . $warning . '' . $content; } $content .= sprintf( '', $isForm ? t('Push this button to update the form to reflect the changes that were made below') : t('Push this button to update the form to reflect the change' . ' that was made in the field on the left'), $this->getView()->icon('cw') . t('Apply') ); } return $content; } }