Scott Elliott
|
| Posted: 10/15/2002, 10:12 AM |
|
I've run into a couple of situations that have puzzled me. To start, I'm using CCS 1.0.7, PHP with templates and MySQL.
1. I have a check box associated with a boolean data type in the database. The field is required (not null). The check box is also required (not visible in the properties window, but verified in the code.) I have set the checked value to be 1, and the unchecked to be 0 with a default of unchecked (all in the property window for the check box.) If I do not check the check box, an error will occur when trying to update or insert stating that a value is required. I'm assuming that the unchecked value of 0 is being interpreted as blank (empty). Is this correct? I have worked around this by modifying the code to not require a value.
2. I have a text box associated with an float data type in the database. The field is required (not null). The text box is also required. I have set the default value to be 0. I have set the Data Type property to be float. If I enter a 0, I get a similar error message as above. Again, I'm assuming that the 0 is being interpreted as a blank (empty). Am I missing something here?
Thanks,
Scott
|
|
|
 |
xbill
|
| Posted: 10/15/2002, 10:47 AM |
|
I have seen the same behaviour.
On the components where I set
"Required" to yes, I can't have a zero
value.
The workaround that I have been using
is to remove the required flag and
either set the default value in the
DB or on the "default value" field
in the control.
It would be nice if the "required"
field could distingiush between a valid
"0" value and a NULL.
-bill
|
|
|
 |
Scott Elliott
|
| Posted: 10/18/2002, 10:22 AM |
|
I have received a response from Yes, software with the following suggestions:
(I have tried these and they work in my situation.)
1. CheckBox issue:
"most probably you have changed the TextBox control to CheckBox. Required property of textbox was set to True. That’s why you see that checkbox required property is set to true in the code, although checkbox control doesn’t have required property. This is the reason of the problem. To overcome it, change control type back to TextBox, set Required to empty, switch back to CheckBox and regenerate the page."
-- This is exactly what happened.
2. Zero is null:
"PHP treat “0” variable value as empty, so you get the warning message. To overcome it edit Validate() function in Classes.php file. Replace
the line
if($this->Required && ($this->Value == "" && $this->Value !== false) && $this->Errors->Count() == 0)
with
if($this->Required && (strlen($this->Value) == 0 && $this->Value !== false) && $this->Errors->Count() == 0)"
-- This fix worked for me
Thanks Support Staff (Helen D.)
|
|
|
 |
michael weaver
|
| Posted: 10/25/2002, 3:09 PM |
|
Thanks Scott - #1 solved my problem, too. Hopefully this will be fixed in the next CCS update.
michael
|
|
|
 |
|