/** * Generates input name for a model attribute. * Note, the attribute name may be modified after calling this method if the name * contains square brackets (mainly used in tabular input) before the real attribute name. * @param \GO\Base\Model $model the data model * @param string $attribute the attribute * @return string the input name */ private function _resolveName($model, $attribute) { if (($pos = strpos($attribute, '[')) !== false) { if ($pos !== 0) { // e.g. name[a][b] return $model->getModelName() . '[' . substr($attribute, 0, $pos) . ']' . substr($attribute, $pos); } if (($pos = strrpos($attribute, ']')) !== false && $pos !== strlen($attribute) - 1) { $sub = substr($attribute, 0, $pos + 1); $attribute = substr($attribute, $pos + 1); return $model->getModelName() . $sub . '[' . $attribute . ']'; } if (preg_match('/\\](\\w+\\[.*)$/', $attribute, $matches)) { $name = $model->getModelName() . '[' . str_replace(']', '][', trim(strtr($attribute, array('][' => ']', '[' => ']')), ']')) . ']'; $attribute = $matches[1]; return $name; } } return $model->getModelName() . '[' . $attribute . ']'; }