Example #1
0
 /**
  * Set Value of a Field
  *
  * @param string $field
  * @param mixed $value
  * @return bool
  */
 public function SetValue($field, $value)
 {
     // Set the Field Values
     switch ($this->Get('type', $field)) {
         case 'date':
             if ($value != '') {
                 if ($time = strtotime($value)) {
                     Form::SetValue($field, date("Y-m-d", $time));
                 } else {
                     Form::SetError($field, 'Invalid date (MM/DD/YYYY)');
                 }
             }
             break;
         case 'time':
             if ($value != '') {
                 if ($time = strtotime($value)) {
                     Form::SetValue($field, date("H:i", $time));
                 } else {
                     Form::SetError($field, 'Invalid time (HH:MM)');
                 }
             }
             break;
         default:
             if (is_array($value)) {
                 Form::SetValue($field, implode(',', $value));
             } else {
                 Form::SetValue($field, $value);
             }
             break;
     }
     return true;
 }