Yii Framework Forum: Is There Better Way To Customize Form Label Names By User? - Yii Framework Forum

Jump to content

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

Is There Better Way To Customize Form Label Names By User? Rate Topic: -----

#1 User is offline   logudotcom 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 46
  • Joined: 04-July 13
  • Location:Chennai, India

Posted 13 November 2013 - 11:45 AM

I have a requirement that User should be allowed to customize the form field label texts. Is there any way to handle this? I am planning to do database way store and allow User to edit that and display dynamically from db the label texts. Please advise.

Check the attachment.Attached File  label.png (13.16K)
Number of downloads: 8
0

#2 User is offline   le_top 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 294
  • Joined: 08-June 10
  • Location:France

Posted 15 November 2013 - 03:06 AM

Of course you have to store this in a database.

You may consider using the translation method in Yii (Yii::t) and use a slightly modified version of CDbMessageSource to look up user specific translations.
That means that your 'attributes()' method in the model just has to use Yii::t (as usual if you do I18N), and that the logic is in the MessageSource class.
Your labels before translation should be something like: 'lb.Model.AttributeName' in order to avoid "translation conflicts" - if your label would be 'From' before translation and you allow the user to change that, then everywher in your application you would get that new translation for 'From';

This may not be a good technique in the long term as it would mix translations with changes to field names, but it may be efficient for a small application.
1

#3 User is offline   logudotcom 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 46
  • Joined: 04-July 13
  • Location:Chennai, India

Posted 15 November 2013 - 07:04 AM

Exactly, I am playing with DB... will use Yii::t , Thanks
0

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