How to rename form elements

Hi all,

is there a way to rename the automatically labeled input fields of a form?

The form elements are declared ‘public’ within the model, e.g.:

public $bday

Now, if I use the form generator this will easily make a form with a text field called ‘bday’ and is labeled like that as well:

<?php echo $form->labelEx($model,'bday'); ?>

<?php echo $form->textfield($model,'bday'); ?>

<?php echo $form->error($model,'bday'); ?>

Is there a way to quickly rename the input field? I would like to have it labeled as ‘Birthday’ instead.

Also, if it is a required field is there are way that it will display an error message stating ‘Birthday can not be blank’ instead of ‘bday can not be blank’?

The only way I can think of is renaming the variable in the model but maybe there is another way as well?

Thank you very much for your help in advance :)

Welcome to the forum.

This is what you are looking for: attributeLabels. (But it’s in the model.)


Thank you Tommy :)

Also, thank you for pushing me on the right track.

I simply added the following to the model:

	public function attributeLabels()


		return array(

			'bday' => 'Birthday'



Again, thank you very much!