LimeSurvey API - Master branch

AlertWidget extends CWidget
in package

Creates a bootstrap alert on given options to fit the admin theme design.

  • in general there are two different alerts:
  1. popup alerts (white background with colored border on left side), which disappear after 3 seconds by default, unless they are danger-alerts. For danger-alerts timeout is set to 10 seconds.
  2. inline alerts (with colored background according to the alert type and no animation on appearance)

If you pass an AR model with "errorSummaryModel", this widget is able to extract the model errors and behaves like ->errorSummary function but with the styling of this widget.

Tags
psalm-suppress

PropertyNotSetInConstructor

Table of Contents

Constants

DEFAULT_ERROR_TIMEOUT  = 6000
DEFAULT_TIMEOUT  = 3000

Properties

$errorSummaryModel  : array<string|int, mixed>
$header  : string
$htmlOptions  : array<string|int, mixed>
$isFilled  : bool
$showCloseButton  : bool
$showIcon  : bool
$tag  : string
$text  : string
$timeout  : int
$type  : string
$icon  : string

Methods

registerClientScript()  : void
Registers required script files
run()  : void
buildHtmlOptions()  : void
Builds htmlOptions related to BS5 alerts, especially the class
handleErrors()  : array<string|int, mixed>
if errorSummaryModel contains something, the errors from the model(s) will be extracted and returned as an array of strings, additionally type and text will be set to default behavior, if those are not passed.
setTimeout()  : void
Sets default timout value if it is not set by the widget call
setTypeAndIcon()  : void
sets icon according to given alert type, also sets default value for type, if unknown string is passed.

Constants

DEFAULT_ERROR_TIMEOUT

public mixed DEFAULT_ERROR_TIMEOUT = 6000

Properties

$errorSummaryModel

public array<string|int, mixed> $errorSummaryModel = \null

| LSActiveRecord | CActiveRecord | CModel | null $model the models whose input errors are to be displayed. This can be either a single model or an array of models

$header

public string $header = ''

the header text displayed in the alert

$htmlOptions

public array<string|int, mixed> $htmlOptions = []

html options

$isFilled

public bool $isFilled = \true

whether the general style is of type "filled", if not the style is "outlined"

$showCloseButton

public bool $showCloseButton = \false

whether the closeButton after the text is shown

$showIcon

public bool $showIcon = \true

whether the icon before the text is shown

$tag

public string $tag = 'div'

the html element in which the alert should be displayed

$text

public string $text = ''

the text displayed in the alert

$timeout

public int $timeout = \null

| null $timeout milliseconds for how long the popup styled alerts should stay (0 = forever)

$type

public string $type = ''

the type of the alert ('success', 'primary', 'secondary', 'danger', 'warning', 'info', 'light', 'dark')

$icon

private string $icon = 'ri-notification-2-line'

icon which is used in the alert

Methods

registerClientScript()

Registers required script files

public registerClientScript() : void

buildHtmlOptions()

Builds htmlOptions related to BS5 alerts, especially the class

private buildHtmlOptions() : void

handleErrors()

if errorSummaryModel contains something, the errors from the model(s) will be extracted and returned as an array of strings, additionally type and text will be set to default behavior, if those are not passed.

private handleErrors() : array<string|int, mixed>
Return values
array<string|int, mixed>

setTimeout()

Sets default timout value if it is not set by the widget call

private setTimeout() : void

setTypeAndIcon()

sets icon according to given alert type, also sets default value for type, if unknown string is passed.

private setTypeAndIcon() : void

        
On this page

Search results