Class Format
Formatter methods for the DataTables Editor
All methods in this class are static with common inputs and returns.
Methods summary
public static
string
|
#
date_sql_to_format( string $val, string[] $data, string $opts )
Convert from SQL date / date time format to a format given by the options
parameter.
Convert from SQL date / date time format to a format given by the options
parameter.
Typical use of this method is to use it with the
Field::getFormatter and Field::setFormatter methods of
DataTables\Editor\Field where the parameters required for this method will be
automatically satisfied.
Parameters
- $val
- Value to convert from MySQL date format
- $data
- Data for the whole row / submitted data
- $opts
- Format to convert to using PHP date() options.
Returns
string Formatted date or empty string on error.
|
public static
string
|
#
date_format_to_sql( string $val, string[] $data, string $opts )
Convert from a format given by the options parameter to a format that
SQL servers will recognise as a date.
Convert from a format given by the options parameter to a format that
SQL servers will recognise as a date.
Typical use of this method is to use it with the
Field::getFormatter and Field::setFormatter methods of
DataTables\Editor\Field where the parameters required for this method will be
automatically satisfied.
Parameters
- $val
- Value to convert to SQL date format
- $data
- Data for the whole row / submitted data
- $opts
- Format to convert from using PHP date() options.
Returns
string Formatted date or null on error.
|
public static
string
|
#
datetime( string $val, string[] $data, string $opts )
Convert from one date time format to another
Convert from one date time format to another
Typical use of this method is to use it with the
Field::getFormatter and Field::setFormatter methods of
DataTables\Editor\Field where the parameters required for this method will be
automatically satisfied.
Parameters
- $val
- Value to convert
- $data
- Data for the whole row / submitted data
- $opts
Array with from and to properties which are the
formats to convert from and to
Returns
string Formatted date or null on error.
|
public static
string
|
#
explode( string $val, string[] $data, string $opts )
Convert a string of values into an array for use with checkboxes.
Convert a string of values into an array for use with checkboxes.
Parameters
- $val
- Value to convert to from a string to an array
- $data
- Data for the whole row / submitted data
- $opts
- Field delimiter
Returns
string Formatted value or null on error.
|
public static
string
|
#
implode( string $val, string[] $data, string $opts )
Convert an array of values from a checkbox into a string which can be
used to store in a text field in a database.
Convert an array of values from a checkbox into a string which can be
used to store in a text field in a database.
Parameters
- $val
- Value to convert to from an array to a string
- $data
- Data for the whole row / submitted data
- $opts
- Field delimiter
Returns
string Formatted value or null on error.
|
public static
string
|
#
nullEmpty( string $val, string[] $data, string $opts )
Convert an empty string to null . Null values are very useful in
databases, but HTTP variables have no way of representing null as a
value, often leading to an empty string and null overlapping. This method
will check the value to operate on and return null if it is empty.
Convert an empty string to null . Null values are very useful in
databases, but HTTP variables have no way of representing null as a
value, often leading to an empty string and null overlapping. This method
will check the value to operate on and return null if it is empty.
Parameters
- $val
- Value to convert to from a string to an array
- $data
- Data for the whole row / submitted data
- $opts
- Field delimiter
Returns
string Formatted value or null on error.
|
public static
string
|
#
ifEmpty( string $val, string[] $data, string $opts )
Formatter that can be used to specify what value should be used if an
empty value is submitted by the client-side (e.g. null, 0, 'Not set',
etc)
Formatter that can be used to specify what value should be used if an
empty value is submitted by the client-side (e.g. null, 0, 'Not set',
etc)
Parameters
- $val
- Value to convert to from a string to an array
- $data
- Data for the whole row / submitted data
- $opts
- Empty value
Returns
string Formatted value or null on error.
|
Constants summary
string |
DATE_ISO_8601
Date format: 2012-03-09. jQuery UI equivalent format: yy-mm-dd
Date format: 2012-03-09. jQuery UI equivalent format: yy-mm-dd
|
|
string |
DATE_ISO_822
Date format: Fri, 9 Mar 12. jQuery UI equivalent format: D, d M y
Date format: Fri, 9 Mar 12. jQuery UI equivalent format: D, d M y
|
|
string |
DATE_ISO_850
Date format: Friday, 09-Mar-12. jQuery UI equivalent format: DD, dd-M-y
Date format: Friday, 09-Mar-12. jQuery UI equivalent format: DD, dd-M-y
|
|
string |
DATE_ISO_1036
Date format: Fri, 9 Mar 12. jQuery UI equivalent format: D, d M y
Date format: Fri, 9 Mar 12. jQuery UI equivalent format: D, d M y
|
|
string |
DATE_ISO_1123
Date format: Fri, 9 Mar 2012. jQuery UI equivalent format: D, d M yy
Date format: Fri, 9 Mar 2012. jQuery UI equivalent format: D, d M yy
|
|
string |
DATE_ISO_2822
Date format: Fri, 9 Mar 2012. jQuery UI equivalent format: D, d M yy
Date format: Fri, 9 Mar 2012. jQuery UI equivalent format: D, d M yy
|
|
string |
DATE_TIMESTAMP
Date format: 1331251200. jQuery UI equivalent format: @
Date format: 1331251200. jQuery UI equivalent format: @
|
|
string |
DATE_EPOCH
Date format: 1331251200. jQuery UI equivalent format: @
Date format: 1331251200. jQuery UI equivalent format: @
|
|