Fix [popup] submission in et2

This commit is contained in:
Nathan Gray 2012-03-02 18:35:49 +00:00
parent 3ad4a94fa9
commit 8d523cad93
2 changed files with 9 additions and 5 deletions

View File

@ -563,6 +563,9 @@ class etemplate_widget
} }
if (is_object($idx)) return false; // given an error in php5.2 if (is_object($idx)) return false; // given an error in php5.2
// Make sure none of these are left
$idx = str_replace(array('[',']'),array('[',']'),$idx);
if (count($idxs = explode('[', $idx, 2)) > 1) if (count($idxs = explode('[', $idx, 2)) > 1)
{ {
$idxs = array_merge(array($idxs[0]), explode('][', substr($idxs[1],0,-1))); $idxs = array_merge(array($idxs[0]), explode('][', substr($idxs[1],0,-1)));

View File

@ -216,7 +216,7 @@ etemplate2.prototype.submit = function(button)
// Button parameter used for submit buttons in datagrid // Button parameter used for submit buttons in datagrid
// TODO: This should probably go in nextmatch's getValues(), along with selected rows somehow. // TODO: This should probably go in nextmatch's getValues(), along with selected rows somehow.
// I'm just not sure how. // I'm just not sure how.
if(button) if(button && !values.button)
{ {
values.button = button.id values.button = button.id
var path = button.getPath(); var path = button.getPath();
@ -285,17 +285,18 @@ etemplate2.prototype.getValues = function(_root)
// check if id contains a hierachical name, eg. "button[save]" // check if id contains a hierachical name, eg. "button[save]"
var id = _widget.id; var id = _widget.id;
var indexes = _widget.id.split('[',2); var indexes = _widget.id.split('[',2); // Discards the others
if (indexes.length > 1) if (indexes.length > 1)
{ {
indexes = [indexes.shift(), indexes.join('[')]; indexes[1] = _widget.id.substring(indexes[0].length+1, _widget.id.length-1); // Add the rest back in, less the trailing ]
indexes[1] = indexes[1].substring(0,indexes[1].length-6); var children = indexes[1].split('][');
var children = indexes[1].split('[]');
if(children.length) if(children.length)
{ {
indexes = jQuery.merge([indexes[0]], children); indexes = jQuery.merge([indexes[0]], children);
} }
path = path.concat(indexes); path = path.concat(indexes);
// Take the last one as the ID
id = path.pop();
} }
// Set the _target variable to that node // Set the _target variable to that node