$newValues[$r] = (array) $newValues[$r];
    $G_FORM->setValues($newValues[$r]);
    //Search dependent fields
    foreach ($newValues[$r] as $k => $v) {
        if (!is_array($v)) {
            $myDependentFields = subDependencies($k, $G_FORM, $aux);
            if (!$found) {
                if (in_array($sFieldName, $myDependentFields)) {
                    $sMasterField = $k;
                    $found = true;
                }
            }
            $_SESSION[$G_FORM->id][$k] = $v;
        } else {
            foreach ($v[$_POST['row']] as $k1 => $v1) {
                $myDependentFields = subDependencies($k1, $G_FORM, $aux, $_POST['grid']);
                if (!$found) {
                    if (in_array($sFieldName, $myDependentFields)) {
                        $sMasterField = $k1;
                        $found = true;
                    }
                }
                $_SESSION[$G_FORM->id][$_POST['grid']][$_POST['row']][$k1] = $v1;
            }
        }
        $dependentFields = array_merge($dependentFields, $myDependentFields);
    }
}
switch ($_POST['function']) {
    case 'showDependentFields':
        echo $json->encode(array_unique($dependentFields));
Example #2
0
function subDependencies($k, &$G_FORM, &$aux)
{
    if (array_search($k, $aux) !== false) {
        return array();
    }
    if (!array_key_exists($k, $G_FORM->fields)) {
        return array();
    }
    if (!isset($G_FORM->fields[$k]->dependentFields)) {
        return array();
    }
    $aux[] = $k;
    $myDependentFields = explode(',', $G_FORM->fields[$k]->dependentFields);
    for ($r = 0; $r < sizeof($myDependentFields); $r++) {
        if ($myDependentFields[$r] == "") {
            unset($myDependentFields[$r]);
        }
    }
    $mD = $myDependentFields;
    foreach ($mD as $ki) {
        $myDependentFields = array_merge($myDependentFields, subDependencies($ki, $G_FORM, $aux));
    }
    return $myDependentFields;
}
Example #3
0
function subDependencies($k, &$G_FORM, &$aux, $grid = '')
{
    if (array_search($k, $aux) !== FALSE) {
        return array();
    }
    if ($grid == '') {
        if (!array_key_exists($k, $G_FORM->fields)) {
            return array();
        }
        if (!isset($G_FORM->fields[$k]->dependentFields)) {
            return array();
        }
        $aux[] = $k;
        if (strpos($G_FORM->fields[$k]->dependentFields, ',') !== false) {
            $myDependentFields = explode(',', $G_FORM->fields[$k]->dependentFields);
        } else {
            $myDependentFields = explode('|', $G_FORM->fields[$k]->dependentFields);
        }
        for ($r = 0; $r < sizeof($myDependentFields); $r++) {
            if ($myDependentFields[$r] == "") {
                unset($myDependentFields[$r]);
            }
        }
        $mD = $myDependentFields;
        foreach ($mD as $ki) {
            $myDependentFields = array_merge($myDependentFields, subDependencies($ki, $G_FORM, $aux));
        }
    } else {
        if (!isset($G_FORM->fields[$grid])) {
            return array();
        }
        if (!array_key_exists($k, $G_FORM->fields[$grid]->fields)) {
            return array();
        }
        if (!isset($G_FORM->fields[$grid]->fields[$k]->dependentFields)) {
            return array();
        }
        $aux[] = $k;
        if (strpos($G_FORM->fields[$grid]->fields[$k]->dependentFields, ',') !== false) {
            $myDependentFields = explode(',', $G_FORM->fields[$grid]->fields[$k]->dependentFields);
        } else {
            $myDependentFields = explode('|', $G_FORM->fields[$grid]->fields[$k]->dependentFields);
        }
        for ($r = 0; $r < sizeof($myDependentFields); $r++) {
            if ($myDependentFields[$r] == "") {
                unset($myDependentFields[$r]);
            }
        }
        $mD = $myDependentFields;
        foreach ($mD as $ki) {
            $myDependentFields = array_merge($myDependentFields, subDependencies($ki, $G_FORM, $aux, $grid));
        }
        //Set field and the dependent field of the grid
        foreach ($myDependentFields as $index => $value) {
            $myDependentFields[$index] = $k . "|" . $value;
        }
    }
    return $myDependentFields;
}