LimeSurvey API - Master branch

DateTimePicker extends CInputWidget
in package

DateTimePicker widget class A simple implementation for date range picker for Twitter Bootstrap 5

Tags
see

Table of Contents

Properties

$events  : array<string|int, string>
$format  : string
$mainId  : string
$name  : string
$pluginOptions  : array<string|int, mixed>
https://getdatepicker.com/6/options.html
$selector  : string

Methods

getConfigScript()  : string
Returns the whole js config which is needed for init of this datepicker
getTempusConfigString()  : string
Creates and returns the main config object for the Tempus Dominus datepicker
init()  : mixed
Initializes the widget.
registerClientScript()  : mixed
Registers required css js files
renderField()  : mixed
Renders the field if no selector has been provided
run()  : mixed
Runs the widget.
getEscapedId()  : string
If id contains brackets, we need to double escape it with \\
getComponentsOptionsString()  : string
Generates and returns the components part of the Tempus Dominus datepicker config
getConvertedTempusOptions()  : array<string|int, mixed>
Converts keys of $options array to the correct options used by this datepicker
getCustomIconsString()  : string
to be able to use the custom buttons of future designs, we need this function to set those. By default this datepicker uses Font Awesome 6, with this function we use FA4 icons as before.
getLocalizationOptionsString()  : string
Generates and returns the localization part of the Tempus Dominus datepicker config
getMomentJsOverrideString()  : string
Returns function overrides for correct date format using momentjs.
getRestrictionsOptionsString()  : string
Generates and returns the restrictions part of the Tempus Dominus datepicker config
getShowComponent()  : bool
Regarding the format of the displayed date, it is determined which calendar components will be shown
getTempusOption()  : string
Exchanges old bootstrap datepicker options which are named differentto the ones used by Tempus Dominus datepicker.
getTranslatedTooltips()  : array<string|int, mixed>
Returns the default tooltips for the datepicker, using the LS translation.
getValue()  : mixed
Returns a specific value from the given array (or the default value if not set).

Properties

$events

public array<string|int, string> $events = array()

the JavaScript event handlers.

$format

public string $format = 'dd/MM/yyyy hh:mm:ss'

the date format.

$pluginOptions

https://getdatepicker.com/6/options.html

public array<string|int, mixed> $pluginOptions = array()

pluginOptions to be passed to datetimepicker plugin. Defaults are:

  • format (custom, introduced by us)
  • allowInputToggle: false
  • showClear: false
  • showToday: false
  • showClose: false
  • sideBySide: false
  • stepping: 1, Controls how much the minutes are changed by
  • locale: default
  • minDate: undefined, Prevents the user from selecting a date/time before this value
  • maxDate: undefined, Prevents the user from selecting a date/time after this value

Following options are not yet done, because there are not needed right now:

  • @TODO enabledDates: undefined
  • @TODO disabledDates: undefined
  • @TODO enabledHours: undefined
  • @TODO disabledHours: undefined
  • @TODO disabledTimeIntervals: undefined
  • @TODO daysOfWeekDisabled, undefined

Display of components like "calendar", "clock", "years", etc is set dynamically via format setting

$selector

public string $selector

if provided, then no input field will be rendered. It will write the JS code for the specified selector.

Methods

getConfigScript()

Returns the whole js config which is needed for init of this datepicker

public getConfigScript( $id) : string
Parameters
$id :
Return values
string

getTempusConfigString()

Creates and returns the main config object for the Tempus Dominus datepicker

public getTempusConfigString() : string
Return values
string

registerClientScript()

Registers required css js files

public registerClientScript() : mixed

renderField()

Renders the field if no selector has been provided

public renderField() : mixed

getEscapedId()

If id contains brackets, we need to double escape it with \\

protected getEscapedId() : string
Return values
string

getComponentsOptionsString()

Generates and returns the components part of the Tempus Dominus datepicker config

private getComponentsOptionsString() : string
Return values
string

getConvertedTempusOptions()

Converts keys of $options array to the correct options used by this datepicker

private getConvertedTempusOptions(array<string|int, mixed> $options) : array<string|int, mixed>
Parameters
$options : array<string|int, mixed>
Return values
array<string|int, mixed>

getCustomIconsString()

to be able to use the custom buttons of future designs, we need this function to set those. By default this datepicker uses Font Awesome 6, with this function we use FA4 icons as before.

private getCustomIconsString() : string
Return values
string

getLocalizationOptionsString()

Generates and returns the localization part of the Tempus Dominus datepicker config

private getLocalizationOptionsString() : string
Return values
string

getMomentJsOverrideString()

Returns function overrides for correct date format using momentjs.

private getMomentJsOverrideString() : string
Return values
string

getRestrictionsOptionsString()

Generates and returns the restrictions part of the Tempus Dominus datepicker config

private getRestrictionsOptionsString() : string
Return values
string

getShowComponent()

Regarding the format of the displayed date, it is determined which calendar components will be shown

private getShowComponent(mixed $component) : bool
Parameters
$component : mixed
Return values
bool

getTempusOption()

Exchanges old bootstrap datepicker options which are named differentto the ones used by Tempus Dominus datepicker.

private getTempusOption(string $option) : string

If there is nothing found in $tempusConvertOptions array, given $option is returned unchanged.

Parameters
$option : string
Return values
string

getTranslatedTooltips()

Returns the default tooltips for the datepicker, using the LS translation.

private getTranslatedTooltips() : array<string|int, mixed>

If there are tooltips defined in the widget call as well, they will also be added and even prioritized over the defaults.

Return values
array<string|int, mixed>

getValue()

Returns a specific value from the given array (or the default value if not set).

private getValue(string $key, array<string|int, mixed> $array[, mixed $defaultValue = 'false' ]) : mixed
Parameters
$key : string

the item key.

$array : array<string|int, mixed>

the array to get from.

$defaultValue : mixed = 'false'

the default value.

Return values
mixed

the value.


        
On this page

Search results