Yii2 attributeLabels() not working

I have a Yii2 Advanced application. I am not using Yii translations.

I have a Gii generated ActiveRecord class AddressBook and have set attributeLabels() as follows:




    public function attributeLabels()

    {

        return [

            'id' => 'ID',

            'user_id' => 'User ID',

            'firstname' => 'Firstname',

            'lastname' => 'Lastname',

            'address' => 'Address',

            'address2' => 'Box, Suite, Apt. etc.',

            'zipcode' => 'Zip Code',

            'city' => 'City',

            'zone_id' => 'State',

            'country_id' => 'Country',

        ];

    }



The form generated by Gii does not display the labels I have set.

I have yet to modify the form to display drop menus for zone_id and country_id, only got as far as updating the labels.

Any ideas?

Could you paste the form code?

It is a standard form generated by Gii. Look at any and you will see what they look like!

I’m sorry, I cannot reproduce this issue. Please paste the model, controller and view code.

Found the problem. Was a copy and paste from my backend controller to the frontend controller:


use backend\models\AddressBook;

Should have changed to ‘frontend’… facepalm