本文整理汇总了PHP中DateField::DateField方法的典型用法代码示例。如果您正苦于以下问题:PHP DateField::DateField方法的具体用法?PHP DateField::DateField怎么用?PHP DateField::DateField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateField
的用法示例。
在下文中一共展示了DateField::DateField方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: jsDateField
/**
* jsDateField::jsDateField()
*
* Constructor: create a new jsdatefield object
*
* @param object &$oForm: the form where the datefield is located on
* @param string $sName: the name of the datefield
* @param string $sMask:
* @param boolean $bRequired:
* @param string $sInterval:
* @param boolean $bIncludeJS: do we include the js file
* @return jsDateField
* @author Teye Heimans
*/
function jsDateField(&$oForm, $sName, $sMask = null, $bRequired = null, $sInterval = null, $bIncludeJS)
{
// call the constructor of the datefield
parent::DateField($oForm, $sName, $sMask, $bRequired, $sInterval);
// check if the mask contains all three fields..
$str = $this->_getFieldsFromMask();
// is the mask ok (can we use a js datefield ?
$this->_isOk = strlen($str) == 3 && strpos($str, 'd') !== false && strpos($str, 'm') !== false && strpos($str, 'y') !== false;
// when not OK, just return a datefield
if (!$this->_isOk) {
return;
}
static $bSetJS = false;
// needed javascript included yet ?
if (!$bSetJS) {
$bSetJS = true;
// add the needed javascript
if ($bIncludeJS == true) {
$oForm->_setJS(FH_FHTML_DIR . "js/calendar_popup.js", true);
$oForm->_setJS("document.write(getCalendarStyles());\n" . "function getDateString( fldForm, fldYear, fldMonth, fldDay ) {\n" . " var frm = document.getElementById(fldForm);\n" . " var objY = frm.elements[fldYear];\n" . " var objM = frm.elements[fldMonth];\n" . " var objD = frm.elements[fldDay];\n" . " var y = objY.options[objY.selectedIndex].value;\n" . " var m = objM.options[objM.selectedIndex].value;\n" . " var d = objD.options[objD.selectedIndex].value;\n" . " if (y=='' || m== '') { \n" . " return null;\n" . " }\n" . " if (d=='') { \n" . " d = 1;\n" . " }\n" . " return y+'-'+m+'-'+d;\n" . "}\n");
}
}
}