<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.7.2" -->
<rss version="2.0">
    <channel>
        <title>field__pullValue[ Search for &quot;&quot;]</title>
        <description></description>
        <link>http://xataface.com/wiki/index.php?-action=single_record_search&amp;-table=wiki&amp;page_id=%3D104&amp;-cursor=0&amp;-skip=0&amp;-limit=30&amp;-mode=list&amp;--subsearch=</link>
        <lastBuildDate>Sat, 25 May 2013 20:57:03 +0100</lastBuildDate>
        <generator>FeedCreator 1.7.2</generator>
        <item>
            <title>field__pullValue</title>
            <link>http://www.xataface.com/wiki/field__pullValue</link>
            <description>&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Field&lt;/th&gt;&lt;th&gt;Value&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td valign=&quot;top&quot;&gt;Page name&lt;/td&gt;&lt;td valign=&quot;top&quot;&gt;field__pullValue&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign=&quot;top&quot;&gt;Page id&lt;/td&gt;&lt;td valign=&quot;top&quot;&gt;104&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign=&quot;top&quot;&gt;Page title&lt;/td&gt;&lt;td valign=&quot;top&quot;&gt;field__pullValue delegate class method&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign=&quot;top&quot;&gt;Content&lt;/td&gt;&lt;td valign=&quot;top&quot;&gt;&lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tr&gt;&lt;td&gt;
&lt;div id=&quot;toc&quot;&gt;&lt;strong&gt;Table of Contents&lt;/strong&gt;
	&lt;div style=&quot;margin-left: 1em;&quot;&gt;&lt;a href=&quot;#toc0&quot;&gt;Example&lt;/a&gt;&lt;/div&gt;
	&lt;div style=&quot;margin-left: 0em;&quot;&gt;&lt;a href=&quot;#toc1&quot;&gt;References&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;This method should always be accompanied by a corresponding &lt;a href=&quot;/wiki/field__pushValue&quot;&gt;field__pushValue&lt;/a&gt; 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.&lt;/p&gt;


&lt;h3 id=&quot;toc0&quot;&gt;Example&lt;/h3&gt;
&lt;p&gt;Given a field &lt;em&gt;start_ip&lt;/em&gt; 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.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;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-&amp;gt;getValue());
        if ( $val !== false ){
            return sprintf('%u', $val );
        }
        return null;
    }
    
    function start_ip__pullValue($record, $el){
        $val = $record-&amp;gt;val('start_ip');
        if ( $val )
            return long2ip($val);
        return $val;
    }
}&lt;/code&gt;&lt;/pre&gt;


&lt;h2 id=&quot;toc1&quot;&gt;References&lt;/h2&gt;
&lt;ul&gt;
    &lt;li&gt; &lt;a href=&quot;/wiki/Delegate_class_methods&quot;&gt;Delegate class methods&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt; &lt;a href=&quot;/wiki/Application_Delegate_Class&quot;&gt;Application Delegate Class&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt; [&lt;a href=&quot;http://dataface.weblite.ca/Dataface_Record&quot; onclick=&quot;window.open(this.href, '_blank'); return false;&quot;&gt;Dataface_Record API docs&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt; &lt;a href=&quot;http://xataface.com/documentation/how-to/how-to-define-custom-serialization-for-fields&quot; onclick=&quot;window.open(this.href, '_blank'); return false;&quot;&gt;How to define custom serialization for fields&lt;/a&gt; - A how-to document.&lt;/li&gt;
&lt;/ul&gt;

&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign=&quot;top&quot;&gt;Keywords&lt;/td&gt;&lt;td valign=&quot;top&quot;&gt;pushValue, pullValue&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign=&quot;top&quot;&gt;Language&lt;/td&gt;&lt;td valign=&quot;top&quot;&gt;en&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;</description>
            <author>field__pullValue</author>
        </item>
    </channel>
</rss>
