LimeSurvey API - Master branch

BaselineModalWidget extends CWidget
in package

BaselineModalWidget

A reusable, content-agnostic Bootstrap 5 modal shell. It renders an empty modal (header/body/footer) that can be filled with arbitrary html and reused throughout the codebase. The body can be filled up-front or asynchronously (e.g. loaded via ajax after the modal is shown).

Render inline (echoes the html where the widget is called): $this->widget('ext.BaselineModalWidget.BaselineModalWidget', [ 'id' => 'my-modal', 'modalTitle' => gT('My title'), 'body' => '

Some content

', 'footer' => '', 'modalSize' => 'modal-lg', ]);

Capture the html to reuse it somewhere else (e.g. from a plugin event where echoing into the page is not possible): $html = Yii::app()->getController()->widget( 'ext.BaselineModalWidget.BaselineModalWidget', ['id' => 'my-modal', 'modalTitle' => gT('My title')], true );

Table of Contents

Properties

$appendToBody  : bool
$body  : string
$footer  : string
$id  : string|null
$modalSize  : string
$modalTitle  : string
$showCloseButton  : bool
$static  : bool
$counter  : int

Methods

getModalId()  : string
Returns the modal id, generating a random one when none was provided.
run()  : void
registerAppendToBodyScript()  : void
Registers a small script that moves the modal to the end of <body>.

Properties

$appendToBody

public bool $appendToBody = \false

if true a script is registered that moves the modal to

public string $footer = ''

the modal footer html (buttons etc.), footer is hidden when empty

$modalSize

public string $modalSize = ''

extra class for the .modal-dialog element, e.g. 'modal-lg' or 'modal-sm'

$showCloseButton

public bool $showCloseButton = \true

whether to render the header close (x) button

$static

public bool $static = \false

if true the modal cannot be closed via keyboard/backdrop click

$counter

private static int $counter = 0

auto-increment counter to guarantee unique ids within one request

Methods

getModalId()

Returns the modal id, generating a random one when none was provided.

public getModalId() : string
Return values
string

registerAppendToBodyScript()

Registers a small script that moves the modal to the end of <body>.

protected registerAppendToBodyScript() : void

Useful to avoid stacking/overflow issues when the modal is rendered deep inside the DOM.


        
On this page

Search results