Hi Klas, thans for responding.
I've managed to fix this with the help of session-variables and URL-extension (live value of current URL) together with codepack-etension (before-render and after-store).
My solution below:
In search-list-form (parent form):
1. Add icon field to redirect to child-content-form (menu-item) to add child-content
In child-content-add-form:
1. Create field (codepack - beforerender).
2. Add session-code (see below) to store URL of first add-content-form (this one contains parent-id in URL).
3. add free field containing URL of current add-form (set bij live-value: URL, custom (all checkboxes on)
4. Add after-store-code (codepack) field to set target-URL ($config['url’], which was saved on before-render), see code below.
Now you can use “save & new” as many times as you like without returning to the main search-list-form after every (child) save. The parentID is provided by replicating the first child-content-form-URL which is stored in session-var and restored in config-URL every time after child-save.
On adding last child-record user can use “save and close-button” so control will be returned to parent search-list-form.
//======================
// before render code
//======================
//
// initialising stuff
//
define( '_JEXEC', 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../..' ));
require_once ( JPATH_BASE. '/includes/defines.php' );
require_once ( JPATH_BASE. '/includes/framework.php' );
$mainframe = JFactory::getApplication('site');
$mainframe->initialise();
$session = JFactory::getSession();
//
// get parentID from field-value (this value is passed by URL-parameter from parent search form)
//
$myparentID = $fields['td_parentid']->value;
//
// save current (first) content-add-form-URL (because this one is working alright)
$myURI = $fields['sysdisplayfield']->value;
//
// second or n-th time (myparentID = empty)? use saved session-URL
// first time? (myparentID NOT empty)? save current URL in session-URL
//
if(empty($myparentID)){
echo "empty....using myURI" . $session->get('myURI');
$fields['td_parentid']->value = $session->get('trParentID');
} else {
$session->set('trParentID', $myparentID);
$session->set('myURI', $myURI);
echo "td_parentid: " . $myparentID;
}
//
//======================
// after save code
//======================
//
// get URL from session en store in config-URL to show add-content-form with correct parent-ID
//
$session = JFactory::getSession();
$config['url'] = $session->get('myURI');