CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Team
    • Issues (Github)
    • YouTube Channel
    • Get Involved
    • Bakery
    • Featured Resources
    • Newsletter
    • Certification
    • My CakePHP
    • CakeFest
    • Facebook
    • Twitter
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.8 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.8
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Cake
    • Auth
      • Storage
    • Cache
      • Engine
    • Collection
      • Iterator
    • Command
    • Console
      • Exception
    • Controller
      • Component
      • Exception
    • Core
      • Configure
        • Engine
      • Exception
      • Retry
    • Database
      • Driver
      • Exception
      • Expression
      • Schema
      • Statement
      • Type
    • Datasource
      • Exception
    • Error
      • Middleware
    • Event
      • Decorator
    • Filesystem
    • Form
    • Http
      • Client
        • Adapter
        • Auth
      • Cookie
      • Exception
      • Middleware
      • Session
    • I18n
      • Formatter
      • Middleware
      • Parser
    • Log
      • Engine
    • Mailer
      • Exception
      • Transport
    • Network
      • Exception
    • ORM
      • Association
      • Behavior
        • Translate
      • Exception
      • Locator
      • Rule
    • Routing
      • Exception
      • Filter
      • Middleware
      • Route
    • Shell
      • Helper
      • Task
    • TestSuite
      • Fixture
      • Stub
    • Utility
      • Exception
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget
  • None

Classes

  • BasicWidget
  • ButtonWidget
  • CheckboxWidget
  • DateTimeWidget
  • FileWidget
  • LabelWidget
  • MultiCheckboxWidget
  • NestingLabelWidget
  • RadioWidget
  • SelectBoxWidget
  • TextareaWidget
  • WidgetLocator

Interfaces

  • WidgetInterface

Class DateTimeWidget

Input widget class for generating a date time input widget.

This class is intended as an internal implementation detail of Cake\View\Helper\FormHelper and is not intended for direct use.

Cake\View\Widget\DateTimeWidget implements Cake\View\Widget\WidgetInterface
Namespace: Cake\View\Widget
Location: View/Widget/DateTimeWidget.php

Properties summary

  • $_select protected
    Cake\View\Widget\SelectBoxWidget
    Select box widget.
  • $_selects protected
    string[]
    List of inputs that can be rendered
  • $_templates protected
    Cake\View\StringTemplate
    Template instance.

Method Summary

  • __construct() public
    Constructor
  • _adjustValue() protected
    Adjust $value based on rounding settings.
  • _daySelect() protected
    Generates a day select
  • _deconstructDate() protected
    Deconstructs the passed date value into all time units
  • _generateNumbers() protected
    Generates a range of numbers
  • _getMonthNames() protected
    Returns a translated list of month names
  • _hourSelect() protected
    Generates a hour select
  • _meridianSelect() protected
    Generates a meridian select
  • _minuteSelect() protected
    Generates a minute select
  • _monthSelect() protected
    Generates a month select
  • _normalizeData() protected
    Normalize data.
  • _secondSelect() protected
    Generates a second select
  • _yearSelect() protected
    Generates a year select
  • render() public
    Renders a date time widget
  • secureFields() public
    Returns a list of fields that need to be secured for this widget.

Method Detail

__construct() public ¶

__construct( Cake\View\StringTemplate $templates , Cake\View\Widget\SelectBoxWidget $selectBox )

Constructor

Parameters
Cake\View\StringTemplate $templates
Templates list.
Cake\View\Widget\SelectBoxWidget $selectBox
Selectbox widget instance.

_adjustValue() protected ¶

_adjustValue( integer $value , array $options )

Adjust $value based on rounding settings.

Parameters
integer $value
The value to adjust.
array $options
The options containing interval and possibly round.
Returns
integer
The amount to adjust $value by.

_daySelect() protected ¶

_daySelect( array $options , Cake\View\Form\ContextInterface $context )

Generates a day select

Parameters
array $options
The options to generate a day select with.
Cake\View\Form\ContextInterface $context
The current form context.
Returns
string

_deconstructDate() protected ¶

_deconstructDate( string|integer|array|DateTime|null $value , array $options )

Deconstructs the passed date value into all time units

Parameters
string|integer|array|DateTime|null $value
Value to deconstruct.
array $options
Options for conversion.
Returns
array

_generateNumbers() protected ¶

_generateNumbers( integer $start , integer $end , array $options = [] )

Generates a range of numbers

Options

  • leadingZeroKey - Set to true to add a leading 0 to single digit keys.
  • leadingZeroValue - Set to true to add a leading 0 to single digit values.
  • interval - The interval to generate numbers for. Defaults to 1.
Parameters
integer $start
Start of the range of numbers to generate
integer $end
End of the range of numbers to generate
array $options optional []
Options list.
Returns
array

_getMonthNames() protected ¶

_getMonthNames( boolean $leadingZero = false )

Returns a translated list of month names

Parameters
boolean $leadingZero optional false
Whether to generate month keys with leading zero.
Returns
array

_hourSelect() protected ¶

_hourSelect( array $options , Cake\View\Form\ContextInterface $context )

Generates a hour select

Parameters
array $options
The options to generate an hour select with
Cake\View\Form\ContextInterface $context
The current form context.
Returns
string

_meridianSelect() protected ¶

_meridianSelect( array $options , Cake\View\Form\ContextInterface $context )

Generates a meridian select

Parameters
array $options
The options to generate a meridian select with.
Cake\View\Form\ContextInterface $context
The current form context.
Returns
string

_minuteSelect() protected ¶

_minuteSelect( array $options , Cake\View\Form\ContextInterface $context )

Generates a minute select

Parameters
array $options
The options to generate a minute select with.
Cake\View\Form\ContextInterface $context
The current form context.
Returns
string

_monthSelect() protected ¶

_monthSelect( array $options , Cake\View\Form\ContextInterface $context )

Generates a month select

Parameters
array $options
The options to build the month select with
Cake\View\Form\ContextInterface $context
The current form context.
Returns
string

_normalizeData() protected ¶

_normalizeData( array $data )

Normalize data.

Parameters
array $data
Data to normalize.
Returns
array
Normalized data.

_secondSelect() protected ¶

_secondSelect( array $options , Cake\View\Form\ContextInterface $context )

Generates a second select

Parameters
array $options
The options to generate a second select with
Cake\View\Form\ContextInterface $context
The current form context.
Returns
string

_yearSelect() protected ¶

_yearSelect( array $options , Cake\View\Form\ContextInterface $context )

Generates a year select

Parameters
array $options
Options list.
Cake\View\Form\ContextInterface $context
The current form context.
Returns
string

render() public ¶

render( array $data , Cake\View\Form\ContextInterface $context )

Renders a date time widget

  • name - Set the input name.
  • disabled - Either true or an array of options to disable.
  • val - A date time string, integer or DateTime object
  • empty - Set to true to add an empty option at the top of the option elements. Set to a string to define the display value of the empty option.

In addition to the above options, the following options allow you to control which input elements are generated. By setting any option to false you can disable that input picker. In addition each picker allows you to set additional options that are set as HTML properties on the picker.

  • year - Array of options for the year select box.
  • month - Array of options for the month select box.
  • day - Array of options for the day select box.
  • hour - Array of options for the hour select box.
  • minute - Array of options for the minute select box.
  • second - Set to true to enable the seconds input. Defaults to false.
  • meridian - Set to true to enable the meridian input. Defaults to false. The meridian will be enabled automatically if you choose a 12 hour format.

The year option accepts the start and end options. These let you control the year range that is generated. It defaults to +-5 years from today.

The month option accepts the name option which allows you to get month names instead of month numbers.

The hour option allows you to set the following options:

  • format option which accepts 12 or 24, allowing you to indicate which hour format you want.
  • start The hour to start the options at.
  • end The hour to stop the options at.

The start and end options are dependent on the format used. If the value is out of the start/end range it will not be included.

The minute option allows you to define the following options:

  • interval The interval to round options to.
  • round Accepts up or down. Defines which direction the current value should be rounded to match the select options.
Parameters
array $data
Data to render with.
Cake\View\Form\ContextInterface $context
The current form context.
Returns
string
A generated select box.
Throws
RuntimeException
When option data is invalid.
Implementation of
Cake\View\Widget\WidgetInterface::render()

secureFields() public ¶

secureFields( array $data )

Returns a list of fields that need to be secured for this widget.

When the hour picker is in 24hr mode (null or format=24) the meridian picker will be omitted.

Parameters
array $data
The data to render.
Returns
array
Array of fields to secure.
Implementation of
Cake\View\Widget\WidgetInterface::secureFields()

Properties detail

$_select ¶

protected Cake\View\Widget\SelectBoxWidget

Select box widget.

$_selects ¶

protected string[]

List of inputs that can be rendered

[
    'year',
    'month',
    'day',
    'hour',
    'minute',
    'second',
    'meridian',
]

$_templates ¶

protected Cake\View\StringTemplate

Template instance.

Follow @CakePHP
#IRC
OpenHub
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Logos & Trademarks
  • Community
  • Team
  • Issues (Github)
  • YouTube Channel
  • Get Involved
  • Bakery
  • Featured Resources
  • Newsletter
  • Certification
  • My CakePHP
  • CakeFest
  • Facebook
  • Twitter
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs