There has been an issue that affects the natural urge of users to “multi-task”. To highlight the issue:
- Navigate to a master list page
- Open a master/detail Add page for master record 1 …IN A NEW TAB
- Switch back to the master list page browser tab
- Open another master/detail Add page for master record 2 …IN A NEW TAB
- Switch back to the browser tab for master record 1
- Add the new detail record
- Check the detail records for master record 1 - the new record will not be there
- Check the detail records for master record 2 …and the new detail record will appearThe reason for this unwanted behaviour is that PHPM only records details of the most recently viewed master record in the browser session.Previously, the only solutions to this problem were:
- never use more than one browser tab (hardly a convenient approach!), or
- work with multiple browsers and use one tab in each (less inconvenient, but still not ideal)However, the following code snippets resolve this problem cleanly and effectively: (v2018)1) Add the following to Client Scripts > Global > Pages with header/footer > Startup Script:
if (!window.name)
window.name = ew.random();
$('a').each(function() {
if ($(this).data('toggle') === 'tab')
return;
var url = $(this).attr('href');
var hash = '';
if (!url || url == "#" || url.indexOf('javascript:') > -1)
return;
if (url.indexOf('#') > -1) {
var _url = url.split('#');
url = _url[0];
hash = '#' + _url[1];
if (hash == '#')
hash = '';
}
var _query = url.split('?');
if (_query[1]) {
var query = '?' + _query[1];
var param = {};
query.replace(/(?:\?|&)([^&=]*)=?([^&]*)/g, function ($0, $1, $2) {
if ($1)
param[$1] = $2;
});
param['tab'] = window.name;
_query[1] = '?';
for (var index in param)
_query[1] += index + '=' + param[index] + '&';
_query[1] = _query[1].substr(0, _query[1].length - 1);
url = _query[0] + _query[1];
}
else
url += '?tab=' + window.name;
$(this).attr('href', url + hash);
});
$('form').each(function() {
var action = $(this).attr('action');
var method = $(this).attr('method');
if (!method || method.toLowerCase() == 'post')
$('<input type="hidden" name="tab" value="' + window.name + '" />').prependTo($(this));
else if (action)
$(this).attr('action', action + (action.indexOf('?') > -1 ? '&' : '?') + 'tab=' + window.name);
});
$('div[onmousedown]').each(function() {
var mousedown = $(this).attr('onmousedown');
$(this).attr('onmousedown', mousedown.replace('\',', '&tab=' + window.name + '\','));
});
- Update the following phpfn.php functions as shown:
for v2020:
// Get session value
public function getSessionValue()
{
return @$_SESSION[PROJECT_NAME . "_" . $this->TableVar . "_" . $this->FieldVar . "_SessionValue" . (isset($_REQUEST["tab"]) ? "_" . $_REQUEST["tab"] : "")];
}
// Set session value
public function setSessionValue($v)
{
$_SESSION[PROJECT_NAME . "_" . $this->TableVar . "_" . $this->FieldVar . "_SessionValue" . (isset($_REQUEST["tab"]) ? "_" . $_REQUEST["tab"] : "")] = $v;
}
for v2018:
// Get session value
public function getSessionValue()
{
return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . $this->FieldVar . "_SessionValue" . (isset($_REQUEST["tab"]) ? "_" . $_REQUEST["tab"] : "")];
}
// Set session value
public function setSessionValue($v)
{
$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . $this->FieldVar . "_SessionValue" . (isset($_REQUEST["tab"]) ? "_" . $_REQUEST["tab"] : "")] = $v;
}
** Remember not to overwrite phpfn.php after making the changes!