Share » Forums » Setup & design » ezemailtype.php bug?

ezemailtype.php bug?

ezemailtype.php bug?

Tuesday 28 July 2009 3:34:27 am - 2 replies

Modified on Tuesday 28 July 2009 3:35:47 am by Luis Micunco

Author Message

Luis Micunco

Tuesday 28 July 2009 3:46:17 am

Full function here:

/*!
     Validates the input and returns true if the input was
     valid for this datatype.
    */
    function validateObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
    {
        if ( $http->hasPostVariable( $base . '_data_text_' . $contentObjectAttribute->attribute( 'id' ) ) )
        {
            $email = $http->postVariable( $base . '_data_text_' . $contentObjectAttribute->attribute( 'id' ) );
            $classAttribute = $contentObjectAttribute->contentClassAttribute();

            $trimmedEmail = trim( $email );

            if ( $trimmedEmail == "" )
            {
                // we require user to enter an address only if the attribute is not an informationcollector
                if ( !$classAttribute->attribute( 'is_information_collector' ) and
                     $contentObjectAttribute->validateIsRequired() )
                {
                    $contentObjectAttribute->setValidationError( ezi18n( 'kernel/classes/datatypes',
                                                                         'The email address is empty.' ) );
                    return eZInputValidator::STATE_INVALID;
                }
            }
            else
            {
                // if the entered address is not empty then we should validate it in any case
                return $this->validateEMailHTTPInput( $trimmedEmail, $contentObjectAttribute );
            }
        }
        else if ( !$classAttribute->attribute( 'is_information_collector' ) and $contentObjectAttribute->validateIsRequired() )
        {
            $contentObjectAttribute->setValidationError( ezi18n( 'kernel/classes/datatypes', 'Missing email input.' ) );
            return eZInputValidator::STATE_INVALID;
        }

        return eZInputValidator::STATE_ACCEPTED;
    }

Peter Keung

Tuesday 28 July 2009 8:41:49 am

Your form is probably missing a required attribute (not just that someone didn't fill it in, but it's not even being posted as empty). Make sure that all necessary form fields are present, and that they are named correctly. To do this, you can double-check with how all fields would be named if they were output using attribute_view_gui.

http://www.mugo.ca
Mugo Web, eZ Partner in Vancouver, Canada

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu