Open seanccsmith opened 4 years ago
This is the code snippet Ken found that's controlling this, I'm not sure exactly where it's located in DURC:
public static function formatForStorage( $field_name, $field_type, $value, $model = null)
{
$formattedValue = $value;
if ( self::mapColumnDataTypeToInputType( $field_type, $field_name ) == 'boolean' ) {
//support obvious notions of truth
if ( $value === 'on' || $value === 'true' || $value === true || $value > 0 ) {
//this allows us to support the use of 'on'/'true' etc for trueness
$formattedValue = 1;
} else {
//if it is a boolean and it is not obviously true.. then it is false..
$formattedValue = 0;
}
As discovered when dealing with issue #61 , Boolean typed columns are being converted before they reach the validators. It looks like this was a workaround from before the validators were implemented, and should probably be deprecated now in favor of allowing the validators to catch any bad values and requiring the user to explicitly change them to an allowed value.