/** * This function attempts to find a repopulate var based on the name of the element and * set the value, unless that value is not already set. * * @param array $data The elements data array, used to check if the key value exists * @param string $value The current elements value, this is set if it is currently empty * @return void */ protected function _attemptRepopulate($name, $value, $returnValue = NULL) { if (!is_null($value)) { return $value; } if (substr($name, 0, 2) == '__') { return $value; } // if ((!is_null($returnValue)) AND ($pos = strpos($name, '[]'))) // { // $parentArray = substr($name, 0, $pos); // // $subArray = substr($name, $pos + 2); // // foreach (self::$repopulateValues as $key => $repopulateValue) // { // if (!strstr($key, $parentArray)) // { // continue; // } // // if (!strstr($key, $subArray)) // { // continue; // } // // if ($returnValue == $repopulateValue) // { // return TRUE; // } // } // } // get the first part of the name (up to the first [) list($varname) = explode('[', $name); if (is_object(View::$instance) and View::$instance->is_set($varname)) { $viewVar = View::$instance->{$varname}; if (is_string($viewVar) or is_bool($viewVar)) { return $viewVar; } $viewVar = arr::smart_cast($viewVar); if (!is_null($viewValue = arr::get_string($viewVar, $name, TRUE))) { return $viewValue; } } if (!is_null($postValue = arr::get_string($_POST, $name))) { return $postValue; } return $value; }