|
|
|
The problem :
when i used several 'choosecoursefile' element with an array of it, the return key of the value is for example :
file[0]
file[1]
and not an array of file.
The solution :
The problem is in the 'MoodleQuickForm_choosecoursefile' class with the function 'exportValue' (file : \lib\form\choosecoursefile.php).
The original code is :
#
function exportValue(&$submitValues, $assoc = false)
{
$value = null;
$valuearray = $this->_elements[0]->exportValue($submitValues[$this->getName()], true);
$value[$this->getName()]=$valuearray['value'];
return $value;
}
#
I proposed this modification wich works fine
#
function exportValue(&$submitValues, $assoc = false)
{
$value = null;
$valuearray = $this->_elements[0]->exportValue($submitValues[$this->getName()], true);
$name = $this->getName();
if (!strpos($name, '[')) {
$value[$this->getName()]=$valuearray['value'];
return $value;
} else {
$valueAry = array();
$myIndex = "['" . str_replace(array(']', '['), array('', "']['"), $name) . "']";
eval("\$valueAry$myIndex = \$valuearray['value'];");
return $valueAry;
}
}
#
|
|
Description
|
The problem :
when i used several 'choosecoursefile' element with an array of it, the return key of the value is for example :
file[0]
file[1]
and not an array of file.
The solution :
The problem is in the 'MoodleQuickForm_choosecoursefile' class with the function 'exportValue' (file : \lib\form\choosecoursefile.php).
The original code is :
#
function exportValue(&$submitValues, $assoc = false)
{
$value = null;
$valuearray = $this->_elements[0]->exportValue($submitValues[$this->getName()], true);
$value[$this->getName()]=$valuearray['value'];
return $value;
}
#
I proposed this modification wich works fine
#
function exportValue(&$submitValues, $assoc = false)
{
$value = null;
$valuearray = $this->_elements[0]->exportValue($submitValues[$this->getName()], true);
$name = $this->getName();
if (!strpos($name, '[')) {
$value[$this->getName()]=$valuearray['value'];
return $value;
} else {
$valueAry = array();
$myIndex = "['" . str_replace(array(']', '['), array('', "']['"), $name) . "']";
eval("\$valueAry$myIndex = \$valuearray['value'];");
return $valueAry;
}
}
# |
Show » |
|