Custom attribute label

Sometimes we need to define a label for an attribute and another one for the same attribute at validation.

Example :

In the case of our default error message (internal Yii message) is "{attribute} must be an integer", and our :


public function attributeLabels() 

    {

        return array(

            'attribute' => 'Year of birth',

         ......



our forms will look likes the following :


Year of birth : <input type="text" ...>

But at validation that label should look like the following "The Year of birth you entered" if we want to get a message like "The Year of birth you entered must be an integer".

So I suggest the possibility to define a more prior label at rules (for validation) :


    public function rules()

    {

            array('attribute', 'integerOnly' => true, 'priorLabel' => 'The Year of birth you entered'),

     ......

Or simply make another function for validation labels like :


public function validationLabels() 

    {

        return array(

            'attribute' => 'The year of birth you entered',

         ......

    }

and of course :


public function fieldsLabels() 

    {

        return array(

            'attribute' => 'Year of birth :',

         ......

    }