Yii Framework Forum: Activelabelex() With Custom Text - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Activelabelex() With Custom Text Rate Topic: -----

#1 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,035
  • Joined: 30-October 09
  • Location:UK

Posted 13 June 2013 - 03:08 PM

Suppose I have the following:

<?php echo $form->labelEx($user, 'email_address'); ?>


in attributeLabels() function I have:

'email_address' => 'Email Address',


On the main signup form the label is displayed as per above. However in the user account area the label needs to be displayed as: 'Your Email Address:'

Now I know I can just manually enter this text as the second parameter of labelEx(), however this means it is no longer a 'model' label and as such it won't render the "required" asterisk and nor will it highlight upon error.

So what is the best way of going about this?
0

#2 User is offline   sidewinder 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 218
  • Joined: 08-July 09
  • Location:Poland

Posted 14 June 2013 - 07:34 AM

You can modify your attributeLabels() function to return different results based on some variable value. Scenario could be a nice candidate.
---------------------------------------------------------------------
"Never memorize what you can look up in books."
Albert Einstein
0

#3 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,035
  • Joined: 30-October 09
  • Location:UK

Posted 17 June 2013 - 05:58 AM

Anyone got any more ideas?
0

#4 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,035
  • Joined: 30-October 09
  • Location:UK

Posted 17 June 2013 - 06:03 AM

This works:

<?php echo $form->labelEx($user, 'email_address', array('label'=>'Your Email Address:')); ?>

1

#5 User is offline   seenivasan 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 620
  • Joined: 17-June 12
  • Location:Chennai,TamilNadu,India.

Posted 17 June 2013 - 06:22 AM

Dear Friend

One can use the option "label" in htmlOptions.

?php echo $form->labelEx($user, 'email_address',array('label'=>'Your Email Address:')); ?>


Edit:Sorry You have got it. I was not aware of it.
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users