How to get attribute label in yii2?
I got this getAttributeLabel() function here in yii2 document, I use this in the controller. But it causes an error
getAttributeLabel()
Call to undefined function app\controllers\getAttributeLabel()
try it
$model = new ModelName(); print_r($model->attributeLabels());
if you use the code above, you can get an array containing all the model attribute labels
$task = new Task(); //to get single attribute label $label = $task->getAttributeLabel('task_title'); //to get all attribute label $labels = $task->attributeLabels();