Hi, thanks for helping
First, in my template I have a Ditto call :
[+phx:mo=`webGroup`:then=`[[Ditto? &startID=`[*id*]` &level=`1` &tpl=`completeChunk` &orderBy=`id DESC`]]`:else=`[[Ditto? &startID=`[*id*]` &level=`1` &tpl=`nonConnectedChunk` &orderBy=`id DESC`]]`+]
Then, in the completeChunk :
<div class="item" id="item[+id+]">
<!-- (...) anything -->
[!sendToDb!]
[!eForm? &noemail=`true` &formid=`saveItem` &eFormOnBeforeMailSent=`sendToDb` &tpl=`saveItem`!]
</div>
The saveItem chunk looks like that :
<form method="post" action="[~[*id*]~]" id="saveItem" name="saveItem"> <!-- problem : the id is not unique in the page -->
<fieldset>
<label for="saveItem"></label>
<p><input name="iditem" id="iditem" class="text" type="text" value="[*id*]"/></p> <!-- displays the parent's id :( -->
<p><input type="submit" name="contact" id="cfContact" class="button" value="Send"/></p>
</fieldset>
</form>
And finally, here is the sendToDb snippet :
<?php
if (!function_exists('sendToDb')) {
function sendToDb( &$fields ){
global $modx;
// Init our array
$dbTable = array();
// gets the parent's id...
//$dbTable['iditem'] = $modx->documentIdentifier;
//$dbTable['iditem'] = $modx->db->escape($fields['iditem']);
// this works perfectly
$dbTable['idclient'] = $modx->getLoginUserName();
// Run the db insert query
$dbQuery = $modx->db->insert($dbTable, 'myDB');
return true;
}
}
?>