Skip to Content Skip to Menu

[SOLVED] Formatting

  • MAYASIMA
  • MAYASIMA
  • OFFLINE
  • Posts: 183
  • Thanks: 22
  • Karma: 5
9 years 5 months ago - 9 years 5 months ago #264821 by MAYASIMA
[SOLVED] Formatting was created by MAYASIMA
What is the best way to format some CB fields (for example first and last name) to capitalize the first letter of each word and change the remaining letters to lowercase if necessary. So when a user registers like:
Code:
JOHN DOE
cb saves it as follows to the database:
Code:
John Doe

And where should this be done? Is it possible via CB fields or should an auto action be created?

Thanks,

Sima
Last edit: 9 years 5 months ago by krileon.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48477
  • Thanks: 8281
  • Karma: 1443
9 years 5 months ago - 9 years 5 months ago #264856 by krileon
Replied by krileon on topic Formatting
Best way is to leave their name alone. You can't assume how their name is formatted. My last name is a capital first letter then a capital 3rd letter. I can't explain how frustrating it is when systems mess it up. At any rate you could use CB Auto Actions and enable format functions under Parameters to allow them to work on the action. You can then reformat the name as needed. Example usage as follows.

Code:
[cb:parse function="convert" method="uppercasewords"][cb:parse function="convert" method="lowercase"][name][/cb:parse[/cb:parse

The first format function lowercases the entire name. The second uppercases the first letter of each word. Another option is to use CSS and try the following, but it'll only work for the first letter of the name. To work around that you could change the name fields layout to put together first, middle, and lastname substitutions with spans surrounding them then style those spans.

Code:
.mySelector { display: inline-block; text-transform: lowercase; } .mySelector:first-letter { text-transform: capitalize; }


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 9 years 5 months ago by krileon.

Please Log in or Create an account to join the conversation.

  • MAYASIMA
  • MAYASIMA
  • OFFLINE
  • Posts: 183
  • Thanks: 22
  • Karma: 5
9 years 5 months ago #264870 by MAYASIMA
Replied by MAYASIMA on topic Formatting
Yes you are right, it is very frustrating when systems mess that up. I forgot about the various complexities of how names are formed. So I definitely agree that it is better to leave it alone. Thanks for the wise feedback.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum