Code:
processFormData ¶
The processFormData hook is triggered after a form has been submitted. It passes the form data array, the Data Container Array and the files array as arguments and does not expect a return value. It is available from version 2.4.4.
1.// config.php 2.$GLOBALS['TL_HOOKS']['processFormData'][] = array('MyClass', 'myProcessFormData'); 3. 4.// MyClass.php 5.public function myProcessFormData($arrPost, $arrForm, $arrFiles) 6.{ 7. // Do something 8.}
I've not used this hook, but your user input into fields 1 2 and 3 are somewhere in ($arrPost, $arrForm, $arrFiles), as is the record id or any hidden fields etc in your form.
The first step is to understand what is in the arrays passed....
I'm not sure but $arrPost['field1'] should contain the posted value of field1.
I don't know what $arrForm or $arrFiles contain. nor do I know where the record id is, but its in there somewhere.
You'll need to print them out to see...
Then update the database for that record...
Your hook...
Code:
class MyHookClass extends Backend
{
public function myHookFunction($arrPost, $arrForm, $arrFiles)
{
if ($arrPost['FORM_SUBMIT'] == 'auto_my_form_id')
{
$manipulatedData1 = arrPost['field1'].'manipulated';
$manipulatedData2 = arrPost['field2'] + arrPost['field3'];
$this->Database->prepare("UPDATE tl_myTable SET field4=?,field5=? WHERE id=?"
->limit(1)
->execute($manipulatedData1,$manipulatedData2,theRecordId);
}
}
}
Something like that
Bookmarks