Interesting development...
In Modules/DynamicFields/DynamicField.php, I had changed line 210 to read
Code:
if(isset($this->bean->$name)){
$quote = "'";
// Edit by Lou Added '|| data_type == date' below
if($field['data_type'] == 'int' || $field['data_type']== 'float' || $field['data_type']== 'date'){
// End edit by Lou
$quote = '';
if(empty($this->bean->$name) && !is_numeric($this->bean->$name) ){
if(strcmp($field['required_option'], 'required') == 0){
$this->bean->$name = 0;
}else{
$this->bean->$name = 'NULL';
}
}
} so that NULL would be passed in to sql-server as an empty date value instead of an empty string. The reason for this was to keep sql server from defaulting to the date 01/01/1900 12:00:00 AM when an empty string was submitted. Without this, all of my Date custom fields on a form were being saved as 01/01/1900 if no values were explicitly entered, this is just what sql server does for some reason...
That hack worked fine to keep sql-server's default date from showing up in detail view after editing and saving a form, and I thought I had the problem licked.
I went back in and took out the hack, leaving the code in its original form, and now, dates I enter in custom fields are being saved correctly, but all of the other custom dates on the form that are left blank are defaulting to that 01/01/1900.
It seems that sql-server needs some value date instantiated first for the date functions in SUGAR to operate properly.
So here's my question: does anyone know how to keep that 01/01/1900 from showing up in custom date fields that are left empty? In other words, something like, if(date_value == 01/01/1900){ Do not display value;}
What file would need to be changed where to include a conditional similar to that pseudocode? I know, it's an ugly way to do things, but at this point, I'm pretty desperate for a quick fix, and I'm green at coding on top of it....
Many thanks for help,
Louis
Windows XP sp2
IIS 5.1
SQL Server 2005 Express
PHP 5.14
Sugar 4.5.0h
Bookmarks