Changeset 397

Show
Ignore:
Timestamp:
12/10/07 15:09:12 (5 months ago)
Author:
gerd
Message:

trade value of "0" as empty

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/gettext/patForms/Element/Enum.php

    r394 r397  
    433433        $values =   $this->getValues(); 
    434434 
    435         if ($values === false) { 
     435        if( $values === false ) { 
    436436            $this->valid = false; 
    437437            return false; 
    438438        } 
    439439 
     440        $empty  =   ( strlen( $value ) == 0 ); 
     441        if( $value == '0' ) { 
     442            $empty  =   true; 
     443        } 
     444 
    440445        // required & empty 
    441         if( isset( $this->attributes["required"] ) && $this->attributes["required"] == "yes" && strlen( $value ) == 0 ) 
    442         { 
     446        if( isset( $this->attributes['required'] ) && $this->attributes['required'] == 'yes' && $empty ) { 
    443447            $this->addValidationError( 1 ); 
    444448            return false; 
     
    449453        // is value in values list? 
    450454        $found = false; 
    451         foreach( $values as $line => $optionDef ) 
    452         { 
    453             if( $optionDef["value"] == $value ) 
    454             { 
     455        foreach( $values as $line => $optionDef ) { 
     456            if( $optionDef['value'] == $value ) { 
    455457                $found  =   true; 
     458                break; 
    456459            } 
    457         } 
    458  
    459         if( !$found ) 
    460         { 
    461             $this->addValidationError( 2 ); 
    462             return false; 
    463         } 
    464  
    465         return true; 
     460 
     461            if( empty( $optionDef['value'] ) && $empty ) { 
     462                $found  =   true; 
     463                break; 
     464            } 
     465        } 
     466 
     467        if( $found ) { 
     468            return true; 
     469        } 
     470 
     471        $this->addValidationError( 2 ); 
     472        return false; 
    466473    } 
    467474