Commit b8fc9111 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Return to the correct profile tab after edit profile errors

parent 289199d2
......@@ -144,6 +144,10 @@ $elements = array(
'class' => $fieldset != 'general' ? 'collapsed' : '',
'elements' => $items
),
'fs' => array(
'type' => 'hidden',
'value' => $fieldset,
),
'submit' => array(
'type' => 'submitcancel',
'value' => array(get_string('saveprofile','artefact.internal'), get_string('viewmyprofile', 'artefact.internal')),
......
......@@ -9,12 +9,19 @@ addLoadEvent(function() {
forEach(legends, function(legend) {
var a = A({'href': ''}, legend.firstChild);
legend.parentNode.tabLink = a;
a.id = legend.id + '_a';
// Pieforms is unhelpful with legend/fieldset ids; get it from children
var fsid = 'general';
var row = getFirstElementByTagAndClassName('tr', 'html', legend.parentNode);
if (row) {
fsid = getNodeAttribute(row, 'id').replace(/^profileform_(.*)description_container$/, '$1');
}
a.id = fsid + '_a';
connect(a, 'onclick', function(e) {
forEach(fieldsets, function(fieldset) {
if (fieldset == legend.parentNode) {
addElementClass(fieldset.tabLink, 'current-tab');
removeElementClass(fieldset, 'safe-hidden');
$('profileform_fs').value = fsid;
}
else {
removeElementClass(fieldset.tabLink, 'current-tab');
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment