Current Record: fieldname__validate #94

Return to Delegate class methods Table of Contents Synopsis Parameters Returns See Also Synopsis Xataface allows you to add valida...

Current Record: fieldname__validate #94

Return to Delegate class methods Table of Contents Synopsis Parameters Returns See Also Synopsis Xataface allows you to add valida...

fieldname__validate Delegate Class Method

[Permalink]

Return to Delegate class methods

Table of Contents

Synopsis

Xataface allows you to add validation on any particular field in table by adding a fieldname__validate method to the table's delegate class of the form:

function myfield__validate(&$record, $value, &$params){
    if ( $value != 'Steve' ){
        $params['message'] = 'Sorry you must enter "Steve"';
        return false;
    }
    return true;
}

Parameters

  • &$record : A Dataface_Record object encapsulating the record we are validating. Note that the values of this object correspond with the submitted values from the form, and not necessarily the actual values of the record in the database.
  • $value : The value that is being inserted.
  • &$params : An output array that can be used to pass back a message if validation fails. You would set this array's 'message' parameter to be a message.

Returns

Returns a boolean value. True if the value is ok and false if validation failed.

See Also

blog comments powered by Disqus
Powered by Xataface
(c) 2005-2024 All rights reserved