I have a formit form that uses the FormItSaveForm hook.
I have created a modx snippet that includes a PHP file that saves posted data that I need in order to render pins on a web page that displays a Google map.
Additionally, I would like to save the formit form id or hash from the record that got created in the modx_formit_forms table to my custom table.
How would I pass along the id or hash to my PHP file that gets included from a modx snippet I created.
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
include $_SERVER['DOCUMENT_ROOT'] . 'path/to/include/add_location.php';
I’ve included the config.inc.php, config.core.php, and the modx.class.php in my external PHP file and can run functions like writing to the error log
$modx->log(xPDO::LOG_LEVEL_ERROR,LINE);
But still cannot figure out to get the formit form id or hash from the record saved from submitting the form, short of just running a database query that gets the latest id saved to the modx_formit_forms table.
Why do you create a new modX instance in your external PHP file? Can’t you just load a class and pass $modx (and maybe $hook) as a parameter to the constructor?
@halftrainedharry
I don’t get very far with using modx in classes. I cannot even write a log. That’s why I just use a PHP file with functions.
class FiberLocations {
public $modx;
function __construct(modX &$modx) {
$this->modx =& $modx;
}
function handle_requests() {
$this->modx->log(xPDO::LOG_LEVEL_ERROR, __LINE__);
}
}
$fiber_locations = new FiberLocations();
$fiber_locations->handle_requests();