Thanks Bruno, that looks like just what I am after. I can't seem to get it working for a doc ID that is provided by the form:
Formit Call
[[!FormIt?
&hooks=`email,updatePlaces,createOrder,redirect`
&emailTpl=`bookingFormReport`
&emailTo=`[email protected]`
&redirectTo=`9`
]]
Hidden docID field
<input type="hidden" name="pageID" value="[[+fi.pageID]]"/>
CreateOrder snippet
<?php
$docID = $hook->getValue('pageID');
$page = $modx->getObject('modResource', $docID);
$value = $page->getTVValue('attendees');
$items = $modx->fromJSON($value);
$next_id = 1;
//get the next MIGX_id
if (is_array($items)){
foreach ($items as $item){
$id = $modx->getOption('MIGX_id',$item,0)+1;
if ($id > $next_id){
$next_id = $id;
}
}
}else{
$items = array();
}
$item = array(
'MIGX_id' => $next_id,
'name' => $hook->getValue('name'),
);
$items[] = $item;
if (!$page ->setTVValue('attendees', $modx->toJson($items))) {
$modx->log(modX::LOG_LEVEL_ERROR,'There was a problem saving your data!');
return false;
}
my attendees migx was built with the Configurator and just has one field called name. I have created a tv called attendees with the migxConfig set correctly.
[ed. note: g5604 last edited this post 11 years, 10 months ago.]