Class kartik\daterange\DateRangeBehavior
Inheritance | kartik\daterange\DateRangeBehavior » yii\base\Behavior » yii\base\BaseObject |
---|---|
Implements | yii\base\Configurable |
DateRangeBehavior automatically fills the specified attributes with the parsed date range values to work seamlessly with the kartik\daterange\DateRangePicker widget.
Public Properties
Public Methods
Method | Description | Defined By |
---|---|---|
__call() | Calls the named method which is not a class method. | yii\base\BaseObject |
__construct() | Constructor. | yii\base\BaseObject |
__get() | Returns the value of an object property. | yii\base\BaseObject |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\base\BaseObject |
__set() | Sets value of an object property. | yii\base\BaseObject |
__unset() | Sets an object property to null. | yii\base\BaseObject |
afterValidate() | Handles owner 'afterValidate' event. | kartik\daterange\DateRangeBehavior |
attach() | Attaches the behavior object to the component. | yii\base\Behavior |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\base\BaseObject |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\base\BaseObject |
className() | Returns the fully qualified name of this class. | yii\base\BaseObject |
detach() | Detaches the behavior object from the component. | yii\base\Behavior |
events() | Declares event handlers for the $owner's events. | kartik\daterange\DateRangeBehavior |
hasMethod() | Returns a value indicating whether a method is defined. | yii\base\BaseObject |
hasProperty() | Returns a value indicating whether a property is defined. | yii\base\BaseObject |
init() | Initializes the object. | kartik\daterange\DateRangeBehavior |
Protected Methods
Method | Description | Defined By |
---|---|---|
dateToTime() | Parses the given date into a Unix timestamp. | kartik\daterange\DateRangeBehavior |
setOwnerAttribute() | Evaluates the attribute value and assigns it to the given attribute. | kartik\daterange\DateRangeBehavior |
Property Details
The attribute that containing date range value.
The attribute that will receive date value formatted by $dateFormat. Required when $singleDate
is set to true
.
The attribute that will receive range end value formatted by $dateEndFormat. Required when
$singleDate is set to false
.
The PHP date format string. It will be used to format the range end value.
- If set to
null
, this will auto convert the range end value into a Unix timestamp. - If set to
false
, there is no formatting action on the range end value.
See also [[$dateEndAttribute]].
The PHP date format string. It will be used to format the date value.
- If set to
null
, this will auto convert the date value into a Unix timestamp. - If set to
false
, there is no formatting action on the date value.
See also [[$dateAttribute]].
The attribute that will receive range start value formatted by $dateStartFormat. Required when
$singleDate is set to false
.
The PHP date format string. It will be used to format the range start value.
- If set to
null
, this will auto convert the range start value into a Unix timestamp. - If set to
false
, there is no formatting action on the range start value.
See also [[$dateStartAttribute]].
The owner model of this behavior.
The date range separator.
Whether the attribute is a single date.
Method Details
Handles owner 'afterValidate' event.
public void afterValidate ( $event ) | ||
$event | yii\base\Event | Event instance. |
throws | yii\base\InvalidValueException |
---|
Parses the given date into a Unix timestamp.
protected static integer|false dateToTime ( $date ) | ||
$date | string | A date string |
return | integer|false | A Unix timestamp. False on failure. |
---|
Declares event handlers for the $owner's events.
Child classes may override this method to declare what PHP callbacks should be attached to the events of the $owner component.
The callbacks will be attached to the $owner's events when the behavior is attached to the owner; and they will be detached from the events when the behavior is detached from the component.
The callbacks can be any of the following:
- method in this behavior:
'handleClick'
, equivalent to[$this, 'handleClick']
- object method:
[$object, 'handleClick']
- static method:
['Page', 'handleClick']
- anonymous function:
function ($event) { ... }
The following is an example:
[
Model::EVENT_BEFORE_VALIDATE => 'myBeforeValidate',
Model::EVENT_AFTER_VALIDATE => 'myAfterValidate',
]
public array events ( ) | ||
return | array | Events (array keys) and the corresponding event handler methods (array values). |
---|
Initializes the object.
This method is invoked at the end of the constructor after the object is initialized with the given configuration.
public void init ( ) | ||
throws | yii\base\InvalidConfigException |
---|
Evaluates the attribute value and assigns it to the given attribute.
protected void setOwnerAttribute ( $attribute, $dateFormat, $date ) | ||
$attribute | string | The owner attribute name |
$dateFormat | string | The PHP date format string |
$date | string | The date string |