Class kartik\datecontrol\Module
| Inheritance | kartik\datecontrol\Module » yii\base\Module » yii\di\ServiceLocator » yii\base\Component » yii\base\BaseObject |
|---|---|
| Implements | yii\base\Configurable |
| Available since version | 1.0 |
Date control module for Yii Framework 2.0. This module is necessary to configure and use the kartik\datecontrol\DateControl widget in your application.
Public Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| $ajaxConversion | \kartik\datecontrol\boolean, | Whether to use ajax based date conversion from display to save formats. | kartik\datecontrol\Module |
| $aliases | array | List of path aliases to be defined. The array keys are alias names (must
start with @) and the array values are the corresponding paths or aliases. See setAliases() for an
example. |
yii\base\Module |
| $autoWidget | boolean | Whether to automatically use \kartik\widgets based on $type. |
kartik\datecontrol\Module |
| $autoWidgetSettings | \kartik\datecontrol\array, | The auto widget settings that will be used to render the date input when autoWidget is set to true. |
kartik\datecontrol\Module |
| $basePath | string | The root directory of the module. | yii\base\Module |
| $behaviors | yii\base\Behavior[] | List of behaviors attached to this component. | yii\base\Component |
| $components | array | The list of the component definitions or the loaded component instances (ID => definition or instance). | yii\di\ServiceLocator |
| $controllerMap | array | Mapping from controller ID to controller configurations. | yii\base\Module |
| $controllerNamespace | string|null | The namespace that controller classes are in. | yii\base\Module |
| $controllerPath | string | The directory that contains the controller classes. | yii\base\Module |
| $convertAction | string|array | The route/action to convert the date as per the kartik\datecontrol\DateControl::$saveFormat setting in kartik\datecontrol\DateControl widget. | kartik\datecontrol\Module |
| $defaultRoute | string | The default route of this module. | yii\base\Module |
| $displaySettings | array | The format settings for displaying each date attribute. | kartik\datecontrol\Module |
| $displayTimezone | string | The timezone for the displayed date. | kartik\datecontrol\Module |
| $id | string | An ID that uniquely identifies this module among other modules which have the same parent. | yii\base\Module |
| $layout | string|boolean|null | The layout that should be applied for views within this module. | yii\base\Module |
| $layoutPath | string | The root directory of layout files. Defaults to "$viewPath/layouts". | yii\base\Module |
| $module | yii\base\Module|null | The parent module of this module. | yii\base\Module |
| $modules | array | The modules (indexed by their IDs). | yii\base\Module |
| $params | array | Custom module parameters (name => value). | yii\base\Module |
| $saveSettings | array | The format settings for saving each date attribute. | kartik\datecontrol\Module |
| $saveTimezone | string | The timezone for the saved date. | kartik\datecontrol\Module |
| $uniqueId | string | The unique ID of the module. | yii\base\Module |
| $version | string | The version of this module. Note that the type of this property differs in getter and setter. See getVersion() and setVersion() for details. | yii\base\Module |
| $viewPath | string | The root directory of view files. Defaults to "$basePath/views". | yii\base\Module |
| $widgetSettings | array | The widget settings that will be used to render the date input. | kartik\datecontrol\Module |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __call() | Calls the named method which is not a class method. | yii\base\Component |
| __clone() | This method is called after the object is created by cloning an existing one. | yii\base\Component |
| __construct() | Constructor. | yii\base\Module |
| __get() | Returns the value of a component property. | yii\base\Component |
| __isset() | Checks if a property is set, i.e. defined and not null. | yii\base\Component |
| __set() | Sets the value of a component property. | yii\base\Component |
| __unset() | Sets a component property to be null. | yii\base\Component |
| afterAction() | This method is invoked right after an action within this module is executed. | yii\base\Module |
| attachBehavior() | Attaches a behavior to this component. | yii\base\Component |
| attachBehaviors() | Attaches a list of behaviors to the component. | yii\base\Component |
| beforeAction() | This method is invoked right before an action within this module is executed. | yii\base\Module |
| behaviors() | Returns a list of behaviors that this component should behave as. | yii\base\Component |
| canGetProperty() | Returns a value indicating whether a property can be read. | yii\base\Component |
| canSetProperty() | Returns a value indicating whether a property can be set. | yii\base\Component |
| className() | Returns the fully qualified name of this class. | yii\base\BaseObject |
| clear() | Removes the component from the locator. | yii\di\ServiceLocator |
| createController() | Creates a controller instance based on the given route. | yii\base\Module |
| createControllerByID() | Creates a controller based on the given controller ID. | yii\base\Module |
| defaultWidgetOptions() | Gets the default options for the Krajee date/time widgets based on type. |
kartik\datecontrol\Module |
| detachBehavior() | Detaches a behavior from the component. | yii\base\Component |
| detachBehaviors() | Detaches all behaviors from the component. | yii\base\Component |
| ensureBehaviors() | Makes sure that the behaviors declared in behaviors() are attached to this component. | yii\base\Component |
| get() | Returns the component instance with the specified ID. | yii\base\Module |
| getBasePath() | Returns the root directory of the module. | yii\base\Module |
| getBehavior() | Returns the named behavior object. | yii\base\Component |
| getBehaviors() | Returns all behaviors attached to this component. | yii\base\Component |
| getComponents() | Returns the list of the component definitions or the loaded component instances. | yii\di\ServiceLocator |
| getControllerPath() | Returns the directory that contains the controller classes according to $controllerNamespace. | yii\base\Module |
| getDisplayFormat() | Gets the display format for the date type. Derives the format based on the following validation sequence: | kartik\datecontrol\Module |
| getDisplayTimezone() | Gets the display timezone. | kartik\datecontrol\Module |
| getInstance() | Returns the currently requested instance of this module class. | yii\base\Module |
| getLayoutPath() | Returns the directory that contains layout view files for this module. | yii\base\Module |
| getModule() | Retrieves the child module of the specified ID. | yii\base\Module |
| getModules() | Returns the sub-modules in this module. | yii\base\Module |
| getSaveFormat() | Gets the save format for the date type. Derives the format based on the following validation sequence: | kartik\datecontrol\Module |
| getSaveTimezone() | Gets the save timezone. | kartik\datecontrol\Module |
| getUniqueId() | Returns an ID that uniquely identifies this module among all modules within the current application. | yii\base\Module |
| getVersion() | Returns current module version. | yii\base\Module |
| getViewPath() | Returns the directory that contains the view files for this module. | yii\base\Module |
| has() | Returns a value indicating whether the locator has the specified component definition or has instantiated the component. | yii\base\Module |
| hasEventHandlers() | Returns a value indicating whether there is any handler attached to the named event. | yii\base\Component |
| hasMethod() | Returns a value indicating whether a method is defined. | yii\base\Component |
| hasModule() | Checks whether the child module of the specified ID exists. | yii\base\Module |
| hasProperty() | Returns a value indicating whether a property is defined for this component. | yii\base\Component |
| init() | Initializes the module. | kartik\datecontrol\Module |
| initSettings() | Initializes module settings. | kartik\datecontrol\Module |
| off() | Detaches an existing event handler from this component. | yii\base\Component |
| on() | Attaches an event handler to an event. | yii\base\Component |
| parseFormat() | Parse and return format understood by PHP DateTime. | kartik\datecontrol\Module |
| runAction() | Runs a controller action specified by a route. | yii\base\Module |
| set() | Registers a component definition with this locator. | yii\di\ServiceLocator |
| setAliases() | Defines path aliases. | yii\base\Module |
| setBasePath() | Sets the root directory of the module. | yii\base\Module |
| setComponents() | Registers a set of component definitions in this locator. | yii\di\ServiceLocator |
| setControllerPath() | Sets the directory that contains the controller classes. | yii\base\Module |
| setInstance() | Sets the currently requested instance of this module class. | yii\base\Module |
| setLayoutPath() | Sets the directory that contains the layout files. | yii\base\Module |
| setModule() | Adds a sub-module to this module. | yii\base\Module |
| setModules() | Registers sub-modules in the current module. | yii\base\Module |
| setVersion() | Sets current module version. | yii\base\Module |
| setViewPath() | Sets the directory that contains the view files. | yii\base\Module |
| trigger() | Triggers an event. | yii\base\Component |
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| defaultVersion() | Returns default module version. | yii\base\Module |
| initAutoWidget() | Initializes the $autoWidgetSettings property defaults. | kartik\datecontrol\Module |
Events
| Event | Type | Description | Defined By |
|---|---|---|---|
| EVENT_AFTER_ACTION | yii\base\ActionEvent | An event raised after executing a controller action. | yii\base\Module |
| EVENT_BEFORE_ACTION | yii\base\ActionEvent | An event raised before executing a controller action. | yii\base\Module |
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| FORMAT_DATE | 'date' | kartik\datecontrol\Module | |
| FORMAT_DATETIME | 'datetime' | kartik\datecontrol\Module | |
| FORMAT_TIME | 'time' | kartik\datecontrol\Module | |
| MODULE | 'datecontrol' | kartik\datecontrol\Module |
Property Details
Whether to use ajax based date conversion from display to save formats. If
set to false, the plugin will use php-date-formatter.js to convert to the set formats using
client side validation.
Whether to automatically use \kartik\widgets based on $type. Will use these widgets:
- kartik\date\DatePicker when type is set to FORMAT_DATE
- kartik\time\TimePicker when type is set to FORMAT_TIME
- kartik\datetime\DateTimePicker when type is set to FORMAT_DATETIME
If this property is not set, this will default to true.
See also [[initSettings()]].
The auto widget settings that will be used to render the date input when autoWidget is set to true.
An associative array that need to be setup as $type => $settings, where:
$type: string, is one of the FORMAT constants, and$settings: array, the widget settings for the Krajee date/time widgets based on the type.
See also [[initSettings()]].
The route/action to convert the date as per the kartik\datecontrol\DateControl::$saveFormat setting in kartik\datecontrol\DateControl widget.
The format settings for displaying each date attribute. An associative array that need to be setup as
$type => $format, where:
$type: string, one of the FORMAT constants, and
$format: string, the PHP date/time format.
If this is not set, will automatically use the settings from Yii::$app->formatter based on the type setting in
the kartik\datecontrol\DateControl widget.
The timezone for the displayed date. If not set, no timezone setting will be applied for formatting.
See also http://php.net/manual/en/timezones.php.
The format settings for saving each date attribute. An associative array that need to be setup as $type => $format, where:
$type: string, one of the FORMAT constants, and
$format: string, the PHP date/time format. Set this to 'U' to save it in Unix timestamp.
See also [[initSettings()]].
The timezone for the saved date. If not set, no timezone setting will be applied for formatting.
See also http://php.net/manual/en/timezones.php.
The widget settings that will be used to render the date input. An associative array that need
to be setup as $type => $settings, where:
$type: string, is one of the FORMAT constants, and$settings: array, which consists of these keys:class: string, the widget class name for the input widget that will render the date input.options: array, the HTML attributes for the input widget
If $autoWidget is true, this will be autogenerated.
See also [[initSettings()]].
Method Details
Gets the default options for the Krajee date/time widgets based on type.
| public static array defaultWidgetOptions ( $type, $format ) | ||
| $type | string | The date control format type (FORMAT_DATE, FORMAT_DATETIME, or FORMAT_TIME). |
| $format | string | The date-time format pattern. |
| return | array | The widget settings. |
|---|---|---|
Gets the display format for the date type. Derives the format based on the following validation sequence:
- if
dateControlDisplayis set inYii::$app->params, it will be first used - else, the format as set in
displaySettingswill be used from this module - else, the format as set in
Yii::$app->formatterwill be used
| public string getDisplayFormat ( $type ) | ||
| $type | string | The attribute type whether date, datetime, or time |
| throws | yii\base\InvalidConfigException | |
|---|---|---|
Gets the display timezone.
| public string getDisplayTimezone ( ) |
Gets the save format for the date type. Derives the format based on the following validation sequence:
- if
dateControlSaveis set inYii::$app->params, it will be first used - else, the format as set in
displaySettingswill be used from this module - else, the format as set in
Yii::$app->formatterwill be used
| public string getSaveFormat ( $type ) | ||
| $type | string | The attribute type whether date, datetime, or time |
| throws | yii\base\InvalidConfigException | |
|---|---|---|
Gets the save timezone.
| public string getSaveTimezone ( ) |
Initializes the module.
This method is called after the module is created and initialized with property values given in configuration. The default implementation will initialize $controllerNamespace if it is not set.
If you override this method, please make sure you call the parent implementation.
| public void init ( ) |
Initializes the $autoWidgetSettings property defaults.
| protected void initAutoWidget ( ) |
Initializes module settings.
| public void initSettings ( ) |
Parse and return format understood by PHP DateTime.
| public static string parseFormat ( $format, $type ) | ||
| $format | string | The date format pattern in ICU or PHP format. |
| $type | string | The date control format type (FORMAT_DATE, FORMAT_DATETIME, or FORMAT_TIME). |
| throws | yii\base\InvalidConfigException | |
|---|---|---|