function prepVal($field, $val, $config) { // cast val switch (true) { case $def & N_DAO_DATE && $def & N_DAO_TIME: $options = array('language' => 'en', 'format' => 'Y-m-d H:i', 'minYear' => 2000, 'maxYear' => date('Y') + 5); $options = $this->getFieldOptions($field, $options); $attributes = array(); $attributes = $this->getFieldAttributes($field, $attributes); $form->addElement('date', $field, $element_label, $options, $attributes); break; case $def & N_DAO_DATE: $options = array('language' => 'en', 'format' => 'Y-m-d', 'minYear' => 2000, 'maxYear' => date('Y') + 5); $options = $this->getFieldOptions($field, $options); $attributes = array(); $attributes = $this->getFieldAttributes($field, $attributes); $form->addElement('date', $field, $element_label, $options, $attributes); break; case $def & N_DAO_TIME: $options = array('language' => 'en', 'format' => 'H:i:s'); $options = $this->getFieldOptions($field, $options); $attributes = array(); $attributes = $this->getFieldAttributes($field, $attributes); $form->addElement('date', $field, $element_label, $options, $attributes); break; case $def & N_DAO_INT: $attributes = array(); $attributes = $this->getFieldAttributes($field, $attributes); $form->addElement('text', $field, $element_label, $attributes); break; case $def & N_DAO_FLOAT: $attributes = array(); $attributes = $this->getFieldAttributes($field, $attributes); $form->addElement('text', $field, $element_label, $attributes); break; case $def & N_DAO_BOOL: break; case $def & N_DAO_TXT: $attributes = array('rows' => 15, 'cols' => 50); $attributes = $this->getFieldAttributes($field, $attributes); $form->addElement('textarea', $field, $element_label, $attributes); break; case $def & N_DAO_BLOB: // do nothing here since binary fields shouldn't be displayed break; case $def & N_DAO_STR: $attributes = array(); $attributes = $this->getFieldAttributes($field, $attributes); $form->addElement('text', $field, $element_label, $attributes); break; } // map form field types to db field types switch ($field_type) { case 'string': case 'varchar': case 'bpchar': case 'longchar': $val = ValueCast::prepStr($val, $db); break; case 'counter': case 'int': case 'integer': $val = ValueCast::prepInt($val, $db); break; case 'bool': case 'bit': $val = ValueCast::prepBoolean($val, $db); break; case 'real': case 'numeric': case 'float4': case 'float8': $val = ValueCast::prepReal($val, $db); break; case 'timestamp': $val = ValueCast::prepTimestamp($val, $db); break; case 'date': $val = ValueCast::prepDate($val, $db); break; case 'datetime': $val = ValueCast::prepDateTime($val, $db); break; case 'time': $val = ValueCast::prepTime($val, $db); break; case 'year': $val = ValueCast::prepInt($val, $db); break; case 'blob': case 'text': case 'longbinary': $val = ValueCast::prepStr($val, $db); break; default: $val = ValueCast::prepStr($val, $db); } return $val; }