就是如果學生的生日是空白的話,那麼資料庫裡是0000-00-
修改XoopsFormTextDateSelect
紅字部份為增加的code
class XoopsFormTextDateSelect extends XoopsFormText
{
var $_setspace;
function XoopsFormTextDateSelect($caption, $name, $size = 15, $value= 0)
{
if ($value==-1) $this->_setspace=true; else $this->_setspace=false;
$value = !is_numeric($value) ? time() : intval($value);
$this->XoopsFormText($caption, $name, $size, 25, $value);
}
function render()
{
$ele_name = $this->getName();
$ele_value = $this->getValue(false);
$jstime = formatTimestamp( $ele_value, 'F j Y, H:i:s' );
include_once XOOPS_ROOT_PATH.'/include/calendarjs.php';
if ($this->_setspace)
return "<input type='text' name='".$ele_name."' id='".$ele_name."' size='".$this->getSize()."' maxlength='".$this-<getMaxlength()."' value='".''."'".$this->getExtra()." />>input type='reset' value=' ... ' onclick='return showCalendar(\"".$ele_name."\");'>";
else
return "<input type='text' name='".$ele_name."' id='".$ele_name."' size='".$this->getSize()."' maxlength='".$this->getMaxlength()."' value='".date("Y-m-d", $ele_value)."'".$this->getExtra()." /<>input type='reset' value=' ... ' onclick='return showCalendar(\"".$ele_name."\");'>";
}
但是想一想,動到Xoops的核心class好像不好,於是創造了
class.form.php
內容是
class sxsFormTextDateSelect extends XoopsFormText
{
var $_setspace;
function sxsFormTextDateSelect($caption, $name, $size =15, $value= '')
{
if ($value=='0000-00-00') $this->_setspace=true; else $this->_setspace=false;
$value = ($value=='') ? time() : strtotime($value);
$this->XoopsFormText($caption, $name, $size, 25, $value);
}
function render()
{
$ele_name = $this->getName();
$ele_value = $this->getValue(false);
$jstime = formatTimestamp( $ele_value, 'F j Y, H:i:s' );
include_once XOOPS_ROOT_PATH.'/include/calendarjs.php';
if ($this->_setspace)
return "<input type='text' name='".$ele_name."' id='".$ele_name."' size='".$this->getSize()."' maxlength='".$this->getMaxlength()."' value='".''."'".$this->getExtra()." /><input type='reset' value=' ... ' onclick='return showCalendar(\"".$ele_name."\");'>";
else
return "<input type='text' name='".$ele_name."' id='".$ele_name."' size='".$this->getSize()."' maxlength='".$this->getMaxlength()."' value='".date("Y-m-d", $ele_value)."'".$this->getExtra()." /><input type='reset' value=' ... ' onclick='return showCalendar(\"".$ele_name."\");'>";
}
}
然後配合
$tt1 = new sxsFormTextDateSelect("date_title", 'stud_birth', 15, $stud_base['stud_birth']);
呼叫
$tt1->render()使用
就可以了
tyc_tea_class.php 也一併修改。