Twitter Feed

Xataface Maillist

Sign up to receive the Xataface news letter with weekly updates and development tips.

Found 1 of 138 records in table Wiki
Now Showing 1 of 1

Current Record: field__pullValue

field__pullValue delegate class method

Table of Contents

The field__pullValue() delegate class method can be used to transform database from the database for use in an edit/new record form. Sometimes it is the case that we want users to be able to work with data differently than it is stored in the database.

This method should always be accompanied by a corresponding field__pushValue method which performs the inverse operation and is used to transform the value in an edit form into a format that can be stored in the database.


Given a field start_ip that stores an IP address in the database as an unsigned INT, we want to be able to work with the data on the edit form in a friendlier format - the standard IP address dot notation, so we define pullValue and pushValue methods for the field in the table's delegate class.

class tables_ip_blocks {

     * @param Dataface_Record $record The record we are pushing the value
     *        into
     * @param HTML_QuickForm_element $el The QuickForm widget that we are 
     *      retrieving the value from.
    function start_ip__pushValue($record, $el){
        $val = ip2long($el->getValue());
        if ( $val !== false ){
            return sprintf('%u', $val );
        return null;
    function start_ip__pullValue($record, $el){
        $val = $record->val('start_ip');
        if ( $val )
            return long2ip($val);
        return $val;


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