2016-11-04 3 views
3

にすべてatrributeのラベルを取得する私はこのコードどのようYiiの1

`Products::model()->getAttributeLabel('brand_id')` 
var_dump(Products::model()->getAttributeLabel('brand_id')); 

(それはbrand_id、BRAND_NAME、b_yearが含まれています)それだけbrand_idラベルを示しブランドテーブルを持っています。ラベルの代わりにすべてのラベルを表示するにはどうすればよいですか?

答えて

0

この

var_dump(Products::model()->attributeLabels()); 
0

斐伊川attributeLabels()Modelfunctionで試してみてください。 databaseフィールドをキーとしてarrayを返します。

あなただけgetAttributeLabelとしてCActiveRecordで書かれている

var_dump(Products::model()->attributeLabels()); // this will return complete array 

ようがないagrumentsでそれを呼び出す必要があり、すべてのラベルを取得し、それが与えられていないことを期待して定義することにより、引数にするすべてのフィールドlablels

0

Products MODからのリターンすべてのラベルを

$lables = Products::model()->attributeLabels(); 
print_r($labels); 

$lables、これを試してみてください。エル。

関連する問題