Login Retreive lost passwordRegister
Search

Manual  /  Functions  /  Fields  /  DateTextField

(Since version FH3 v1.2.12)

DateTextField
DateTextField (
string $title
string $name
mixed $validator = null,
string $mask = null,
boolean $bParseOtherPresentations = false,
string $extra = null 
)

Arguments:

Name Description
$title The title of the field
$name The name of the field
$validator This can either be the name of your own validation function or the constant name of a predefined validator function. For more information about validators see Validators.
It is also possible to use a method as a validation function. In this case you should pass an array where the first item is the object and the second item the name of the method.

(NOTE: the date is automaticly checked for a correct combination)
$mask The mask which will be used to lay out the date fields. If no mask is given, the default mask is loaded which is set in the config file with the var FH_DATETEXTFIELD_DEFAULT_DISPLAY.

In the mask the following placeholders are replaced:
d = day (2 digits with leading zeros)
D = day
m = month (2 digits with leading zeros)
M = month
y = year (two digits)
Y = year (four digits)

The date will be changed to the correct format when it's being saved into the database. The date will have the same format as given in the mask when it's returned to the user (in your onSaved or OnCorrect function)
$bParseOtherPresentations try to parse other presentations of dateformat
$extra This can be extra information which will be included in the fields html tag. You can add for example some CSS or javascript.

Description:

This function generates a textfield which will be validated as date

Example

<?php  
// include the class  
include('FH3/class.FormHandler.php');  

// make a new form object  
$oForm = new FormHandler();  

// make the datefield  
$oForm -> dateTextField("Birthdate""birthdate");  

// button beneath it  
$oForm -> submitButton("Save");  

// set the 'commit after form' function  
$oForm -> onCorrect("doRun");  

// send the form to the screen  
$oForm -> flush();  

// the function witch handles the code after the form  
function doRun($aData)  
{  
   
// show the birthdate  
   
echo "Your birthday is "$aData["birthdate"];  
}  
?>

Preview image

preview image

See also: DateField  |  jsDateField  |  jsDateTextField

Latest change: 11 July 11 / 09:27

Comments

powered by PHP-GLOBE   © 2004 - 2024 FormHandler. All rights reserved.   -   Open source license