我和你有同樣的問題。
補丁以下文件:
/path/to/yii/framework/web/helpers/CHtml.php
找到方法 'resolveName',用下面的替換:
/**
* Resolves a class name, removing namespaces.
*/
public static function resolveClassName($model){
return end(explode('\\',get_class($model)));
}
/**
* 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 CModel $model the data model
* @param string $attribute the attribute
* @return string the input name
*/
public static function resolveName($model,&$attribute)
{
if(($pos=strpos($attribute,'['))!==false)
{
if($pos!==0) // e.g. name[a][b]
return self::resolveClassName($model).'['.substr($attribute,0,$pos).']'.substr($attribute,$pos);
if(($pos=strrpos($attribute,']'))!==false && $pos!==strlen($attribute)-1) // e.g. [a][b]name
{
$sub=substr($attribute,0,$pos+1);
$attribute=substr($attribute,$pos+1);
return self::resolveClassName($model).$sub.'['.$attribute.']';
}
if(preg_match('/\](\w+\[.*)$/',$attribute,$matches))
{
$name=self::resolveClassName($model).'['.str_replace(']','][',trim(strtr($attribute,array(']['=>']','['=>']')),']')).']';
$attribute=$matches[1];
return $name;
}
}
return self::resolveClassName($model).'['.$attribute.']';
}
希望這有助於!
P.S.對於任何人認爲這是愚蠢的或不必要的,客戶端驗證器不工作,因爲你不能通過使用JavaScript(或至少使用jQuery)的反斜槓選擇一個元素的ID
嗯,我添加了var_dump() var_dump($ _ POST ['LoginForm'])返回「未定義索引」。這只是我的調試方式,無論如何,下次我會使用FB或類似的。你有什麼解決我的問題? – user1077220
如果你只是用它進行調試,如果你正在獲得完整的路徑,這並不重要! – Orlymee