How to change text field label in activeform?

Hi,

I want to create a simple register form. My view register.php looks like this:




<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(

	'id'=>'register-form',

	'enableAjaxValidation'=>true,

)); ?>


	<p class="note">Fields with <span class="required">*</span> are required.</p>


	<div class="row">

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

		<?php echo $form->textField($model,'username'); ?>

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

        <p class="hint">

			Hint: You should use the same username as your email id.

		</p>

	</div>


	<div class="row">

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

		<?php echo $form->passwordField($model,'password'); ?>

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

		

	</div>

    

    <div class="row">

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

		<?php echo $form->passwordField($model,'password2'); ?>

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

	</div>

	


	<div class="row buttons">

		<?php echo CHtml::submitButton('Register'); ?>

	</div>


<?php $this->endWidget(); ?>

</div><!-- form -->



It worked but the “password2” input field’s label shows literal “password2”. I want to change it to “Re-type password”. How to do that?

Thanks!

just change in label name


<?php echo $form->labelEx($model,'Re-type password'); ?>



another way if you want set it permanent in all page, add in attribut label on your model




public function attributeLabels()

{

	return array(

                ....

		'password2' => 'Re-type password',

                ....

	);

}



Thanks. I tried this. However, the requirement markup got removed. Should I also change the password2 to Re-type password in the following code in RegistForm.php?




public function rules()

	{

		return array(

			// username, password and passwords are required

			array('username, password, password2', 'required'),

			// password needs to match password2

			array('password, password2', 'match'),

            // username should be unique

			array('username', 'unique', 'skipOnError'=>true),

		);

	}



did you mean the error not shown ?




public function rules()

        {

                return array(

array('ID_Jabatan, Nama_Jabatan, ID_Organisasi, Status', 'required', 'message'=>''),



did you mean the error not shown ?

the label doesnt concern with the error. are u sure just change the label?




public function rules()

        {

                return array(

                     array('password, password2', 'match', 'message'=>'Retype Password match')

'),

             }



No. I mean the red "*" next to the label that indicates this is a required field is no longer there if I use your first suggestion. Everything else works fine.

I tried your second suggesting, the attribute list, that one really works!

Thanks!