3

I have Brand table(it contains brand_id, brand_name, b_year ) and this code

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

It shows only brand_id label. How can I show all labels instead of one?

phpdev
  • 511
  • 4
  • 22

3 Answers3

0

Try this

var_dump(Products::model()->attributeLabels());
rakesh mallesh
  • 168
  • 1
  • 8
0

Hii attributeLabels() is a function in Model. It return a array with database field as key.

to get all labels you have to just call it with no agruments like

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

Where as getAttributeLabel is written in CActiveRecord and it expect and argument by definition it will not given all fields lablels

Passionate Coder
  • 7,154
  • 2
  • 19
  • 44
0

Please try this,

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

$lables returns all labels from Products model.

Arya
  • 504
  • 2
  • 8
  • 31