Re: New package: DB_DataObject_FormBuilder
| From: | Ron McClain | Date: | Mon, 25 Aug 2003 04:20:16 +0000 |
| Subject: | Re: New package: DB_DataObject_FormBuilder | ||
| References: | 1 2 3 4 5 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-20490@lists.php.net to get a copy of this message | ||
Ok, just making sure ;) Anyhow, I wonder if you could perhaps add a call
to $this->_do->validate() in processForm? That way I can use my existing
validation code for the extended DO classes.
Thanks,
Ron
Ron McClain wrote:
Actually, there's another problem in the same function. If you pass in an array and $timestamp=true, it still will give back a string. Here's a working version. It could be done with less elseifs, but because the && options don't get evaluated past the first one that fails, I think this is efficient.. i.e., do the simple tests first, make sure checkdate is only called once. -Ron function _array2date($date, $timestamp=false) {if($timestamp == false && is_array($date) && checkdate($date['M'], $date['d'], $date['Y'])) { $strDate = $date['Y'].'-'.$date['M'].'-'.$date['d']; } elseif($timestamp == true && is_array($date) && checkdate($date['M'], $date['d'], $date['Y'])) { $strDate = strtotime($date['Y'].'-'.$date['M'].'-'.$date['d']); } elseif($timestamp == true) { $strDate = time(); } else { $strDate = date('Y-m-d', time()); } return $strDate;} Ron McClain wrote:Hi Markus. Finally got some time to look at this. It looks really nice.. been meaning to write it myself ;) Anyhow, I think you have a bug. Shouldn't the elseif condition be is_array? Otherwise, the package looks great. I know I'll make use of it. Just thought I'd point that out. function _array2date($date, $timestamp=false) {if (is_array($date) && checkdate($date['M'], $date['d'], $date['Y'])) { $strDate = $date['Y'].'-'.$date['M'].'-'.$date['d']; } elseif (is_int($date) && $timestamp==true) { --> ^^^^ is_array $strDate = strtotime($date['Y'].'-'.$date['M'].'-'.$date['d']); } else { $strDate = date('Y-m-d', time()); } return $strDate;}