We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8023
    • 4 Posts
    Before I dive into coding more than it takes:
    I’d like to implement an additional handler for FormIt, to save certain data from a form to the database.

    Based on the information I found so far it seems that I’d have to implement a complete package to get what I want.
    Or is there a shortcut?

    - David.
      • 22295
      • 153 Posts
      You just need to add you own hook - a snippet that will process the data after formit validation


      [[!FormIt? &hooks=`yourHook`]]


      and in yourHook snippet - have this:
      $fields = $scriptProperties['fields'];  // get $fields from formit (post-validation)
      ...and all your processing code...
        • 28215
        • 4,149 Posts
        Quote from: drei at Dec 30, 2009, 08:54 AM

        Before I dive into coding more than it takes:
        I’d like to implement an additional handler for FormIt, to save certain data from a form to the database.

        Based on the information I found so far it seems that I’d have to implement a complete package to get what I want.
        Or is there a shortcut?
        What oori posted will help you on the FormIt side.

        That said, you don’t need to build a schema and map/classes to do DB work; but without the classes you wont be able to use newObject, getObject, getCollection, etc. The OOP parts wont work, in other words. The tutorial to building schemas/maps/classes is here:

        http://svn.modxcms.com/docs/display/xPDO20/Creating+a+Model+With+xPDO

        Now, with that said, you can always use PDO with the query function: http://us.php.net/manual/en/pdo.query.php

        $xpdo->query('UPDATE `my_table_name` SET `field` = "value"');
        


        or better yet, exec(): http://us.php.net/manual/en/pdo.exec.php

        $rowCountAffected = $xpdo->exec('UPDATE `my_table_name` SET `field` = "value"');
        echo $rowCountAffected.' rows affected.';
        

          shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com