Menu

Autofill field

JeffD
2023-11-23
2023-11-24
  • JeffD

    JeffD - 2023-11-23

    I created a method that will autofill a field with the sum of 2 fields. How will I trigger the function inside the field and how will I pass the value of the 2 fields to the function? Here is the snippet of my code:

    <class id="UserRequest">
    <fields>
    <field id="var1" xsi:type="AttributeInteger" _delta="define">
    <sql>va1</sql>
    <default_value>
    <is_null_allowed>false</is_null_allowed>
    </default_value></field>
    <field id="var2" xsi:type="AttributeInteger" _delta="define">
    <sql>var2</sql>
    <default_value>
    <is_null_allowed>false</is_null_allowed>
    </default_value></field>
    <field id="total" xsi:type="AttributeInteger" _delta="define">
    <sql>total</sql>
    <default_value>
    <is_null_allowed>false</is_null_allowed>
    </default_value></field>
    </fields>
    <methods>
    <method id="SumNumber" _delta="define">
    <static>false</static>
    <access>public</access>

    <![CDATA
    public function SumNumber($v1, $v2)
    {
    $total = $v1 + $v2;
    return $total;
    }
    ]>
    </ code>
    </method>
    </methods></class>

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2023-11-23

    You'd need to hook in some methods. I would personally use AfterInsert() and AfterUpdate(); and then call the SumNumber() function.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.