Webforms
The class WebformCapture is notnow extendable via SDK::setClass and the main method captureNow has been split up in several methods to facilitate modification of specific behaviours.
For example, to force the value of a field with a dynamic value upon Lead creation:
First we have to register the extension:
SDK::setClass('WebformCapture', 'WebformCaptureCustom', 'modules/SDK/src/CUSTOMER/WebformCaptureCustom.php');
And then extend the prepareParameters method:
<?php
require_once('modules/Webforms/WebformCapture.php');
class WebformCaptureCustom extends WebformCapture {
/**
* Read data from request and populate the necessary fields
*/
protected function prepareParameters(array $request, Webforms_Model $webform) : array {
// call the parent method to fill the standard values
$parameters = parent::prepareParameters($request, $webform);
// populate the field with a random value (makeRandomString is just an example here)
$parameters['my_field_random'] = makeRandomString();
return $parameters;
}
}