Date field represents a date in year/month/day format.
This class consist of three selection fields, that have limited input,
in order to have a correct date input :
- day (1-31)
- month (1-12)
- year (current_year +/- 10)
The only exception is when an empty value is allowed,
i.e. the date is not a necessary value.
Functionality
- set date (value)
- get date (value)
- set timestamp
- get timestamp
- validate
- reinitialise the range of the selectionfields
Methods
Initialises an instance of a Formaid_FieldDate class.
__construct(string $field_name, string $current_value, string $title, string $comment, bool $allow_empty, bool $enable_today) : void
Defines current value and default value.
Parameters
$field_name
string
Name of the date field
$current_value
string
Initial date
$title
string
Title/caption that precedes this field
$comment
string
Comment that is shown after this field
$allow_empty
bool
Allow the date to be empty (0000-00-00)
$enable_today
bool
Enable today checkbox
Checks if INSERT of the value of this field in an SQL record is allowed.
allowSqlInsert() : bool
Inherited
If the Privileges on this field ( allow_change and allow_sql_insert) are set,
it is allowed to insert the value of this field.
inherited_from |
\Formaid_FieldInputAbstract::allowSqlInsert() |
Returns
bool
true if insert is allowed.
Checks if SELECTing the value of this field from an SQL record is allowed.
allowSqlSelect() : bool
Inherited
If the Privileges on this field (allow_show) is set,
it is allowed to select the value of this field.
inherited_from |
\Formaid_FieldInputAbstract::allowSqlSelect() |
Returns
bool
true if select is allowed.
Checks if UPDATE of the value of this field in an SQL record is allowed.
allowSqlUpdate() : bool
Inherited
If the Privileges on this field ( allow_change and allow_sql_update) are set,
it is allowed to update the value of this field.
inherited_from |
\Formaid_FieldInputAbstract::allowSqlUpdate() |
Returns
bool
true if update is allowed.
Disables trimming whitespace of object name
disableTrimName() : void
Inherited
inherited_from |
\Formaid_Object::disableTrimName() |
inherited_from |
\Formaid_Property::disableTrimName() |
inherited_from |
\Formaid_FieldInputAbstract::disableTrimName() |
Display object
display() : void
Inherited
The name of the object is printed to stdout.
inherited_from |
\Formaid_Object::display() |
inherited_from |
\Formaid_Property::display() |
inherited_from |
\Formaid_FieldInputAbstract::display() |
Enables trimming whitespace of object name
enableTrimName() : void
Inherited
inherited_from |
\Formaid_Object::enableTrimName() |
inherited_from |
\Formaid_Property::enableTrimName() |
inherited_from |
\Formaid_FieldInputAbstract::enableTrimName() |
Get display seperator
getDisplaySeparator() : string
Inherited
inherited_from |
\Formaid_Property::getDisplaySeparator() |
inherited_from |
\Formaid_FieldInputAbstract::getDisplaySeparator() |
Returns
string
String separating columns
Generates the HTML string for this element
getDisplayString() : string
Inherited
If the mode is form, a form element is shown :
this includes a title, html tags and a comment
If the mode is value, only the values of a record are shown:
this includes a title and the value in human readable form.
inherited_from |
\Formaid_FieldInputAbstract::getDisplayString() |
Returns
string
Returns the html-code for the input field properties
getFieldPropertiesHtmlString() : string
Inherited
inherited_from |
\Formaid_FieldInputAbstract::getFieldPropertiesHtmlString() |
Returns
string
Returns a html string of the object.
getHtmlString() : string
A field objected is converted to a html string to display it in a web page
or web form.
Returns
string
html string
Returns name of the object
getName() : string
Inherited
inherited_from |
\Formaid_Object::getName() |
inherited_from |
\Formaid_Property::getName() |
inherited_from |
\Formaid_FieldInputAbstract::getName() |
Returns
string
object name
Get the timestamp.
getTimestamp() : integer
Convert the current value (date) to a timestamp value.
Returns
integer
timestamp
Returns current value
getValue() : string
Inherited
inherited_from |
\Formaid_Property::getValue() |
inherited_from |
\Formaid_FieldInputAbstract::getValue() |
Returns
string
current value
Returns a value formatted to show on a web page.
getValueDisplayString(bool $specialchars) : string
Inherited
The returned value is human readable, this means that it will be
converted from an abstract value in a database to a human readable
equivalent.
inherited_from |
\Formaid_FieldInputAbstract::getValueDisplayString() |
Parameters
$specialchars
bool
Convert with htmlspecialchars, default = no
Returns
string
Initialise (populate) the selection fields (day, month, year)
init() : void
After setting the allow_empty switch, or changing the year-range,
the possible values of the selection fields have to be recreated.
todo |
Init after allow_empty, year_range (or change value?) |
todo |
refactor, using clear (to be implemented) and addItem() |
Checks if current value is empty
isEmpty() : bool
Inherited
inherited_from |
\Formaid_Property::isEmpty() |
inherited_from |
\Formaid_FieldInputAbstract::isEmpty() |
Returns
bool
true if empty
Checks if object name is empty
isNameEmpty() : bool
Inherited
inherited_from |
\Formaid_Object::isNameEmpty() |
inherited_from |
\Formaid_Property::isNameEmpty() |
inherited_from |
\Formaid_FieldInputAbstract::isNameEmpty() |
Returns
bool
true if empty
Reads value in the $_GET array
readGetValue() : void
The field value on a form is submitted and made available by the
webserver in the $_GET array.
The GET value of each subfield (day, month, year) is retrieved and the
value of this object calculated from the subfield values, format YYYY-MM-DD.
If the today checkbox is checked, the date of today is used, the other values
are omitted.
Reads value in the $_POST array
readPostValue() : void
The field value on a form is submitted and made available by the
webserver in the $_POST array.
The POST value of each subfield (day, month, year) is retrieved and the
value of this object calculated from the subfield values, format YYYY-MM-DD.
If the today checkbox is checked, the date of today is used, the other values
are omitted.
Reads value from an sql-row array
readSqlValue(array $sql_row) : void
Inherited
This function checks if the value exist
and sets the value of this object.
inherited_from |
\Formaid_FieldInputAbstract::readSqlValue() |
Parameters
$sql_row
array
row from sql_result
Reset date value
resetValue() : void
Set date to the default value
setDefault(string $value) : void
When the parameter is set,
the default value is changed to the new default value.
Then the current value is set to the (new) default value.
Parameters
Sets new name for the object
setName(string $new_name) : void
Inherited
inherited_from |
\Formaid_Object::setName() |
inherited_from |
\Formaid_Property::setName() |
inherited_from |
\Formaid_FieldInputAbstract::setName() |
Parameters
Set the timestamp.
setTimestamp(int $value) : void
Set the current value (date) to a timestamp value.
Parameters
Set date value.
setValue(\date $value) : void
Parameters
$value
\date
new date value (format : YYYY-MM-DD)
Show object
show() : void
Inherited
The name of the object is printed to stdout.
inherited_from |
\Formaid_Object::show() |
inherited_from |
\Formaid_Property::show() |
inherited_from |
\Formaid_FieldInputAbstract::show() |
Validate the current value (date).
validateValue() : void
The current value must have a valid date format.
Returns name formatted for displaying
getDisplayName() : string
Inherited
inherited_from |
\Formaid_Object::getDisplayName() |
inherited_from |
\Formaid_Property::getDisplayName() |
inherited_from |
\Formaid_FieldInputAbstract::getDisplayName() |
Returns
string
formatted object name
Returns value formatted for displaying
getDisplayValue() : string
Inherited
access |
protected |
inherited_from |
\Formaid_Property::getDisplayValue() |
inherited_from |
\Formaid_FieldInputAbstract::getDisplayValue() |
Returns
string
formatted object value
Updates the value of the input field status
_updateStatus() : void
Inherited
When the input field is disabled, Privilege allow_change is false,
the status is set to disabled.
In all other cases, the status is set to default (= active).
access |
private |
inherited_from |
\Formaid_FieldInputAbstract::_updateStatus() |
Properties
$auto_update : bool
Inherited
access |
public |
inherited_from |
\Formaid_FieldInputAbstract::$$auto_update |
$layout_class : string
Inherited
access |
public |
inherited_from |
\Formaid_FieldInputAbstract::$$layout_class |
$privileges : array
Inherited
access |
public |
inherited_from |
\Formaid_FieldInputAbstract::$$privileges |
$properties : array
Inherited
access |
public |
inherited_from |
\Formaid_FieldInputAbstract::$$properties |
$title : string
Inherited
access |
public |
inherited_from |
\Formaid_FieldInputAbstract::$$title |
$urlReturnParamEnable : bool
Inherited
access |
public |
inherited_from |
\Formaid_FieldInputAbstract::$$urlReturnParamEnable |
$urlReturnParamName : string
Inherited
Default is the field name.
access |
public |
inherited_from |
\Formaid_FieldInputAbstract::$$urlReturnParamName |
$current_value : string
Inherited
access |
protected |
inherited_from |
\Formaid_Property::$$current_value |
inherited_from |
\Formaid_FieldInputAbstract::$$current_value |
$default_value : string
Inherited
access |
protected |
inherited_from |
\Formaid_Property::$$default_value |
inherited_from |
\Formaid_FieldInputAbstract::$$default_value |
$displaySeparator : string
Inherited
access |
protected |
inherited_from |
\Formaid_Property::$$displaySeparator |
inherited_from |
\Formaid_FieldInputAbstract::$$displaySeparator |
$encoding : string
Inherited
access |
protected |
inherited_from |
\Formaid_Object::$$encoding |
inherited_from |
\Formaid_Property::$$encoding |
inherited_from |
\Formaid_FieldInputAbstract::$$encoding |
$name : string
Inherited
access |
protected |
inherited_from |
\Formaid_Object::$$name |
inherited_from |
\Formaid_Property::$$name |
inherited_from |
\Formaid_FieldInputAbstract::$$name |
$status : string
Inherited
Used to transfer the
status when submitting a form.
access |
public |
inherited_from |
\Formaid_FieldInputAbstract::$$status |
$_trimName : bool
Inherited
access |
private |
inherited_from |
\Formaid_Object::$$_trimName |
inherited_from |
\Formaid_Property::$$_trimName |
inherited_from |
\Formaid_FieldInputAbstract::$$_trimName |