CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Autoformat fields and exta validation
Pages: [1]

Author Topic: Autoformat fields and exta validation  (Read 1464 times)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Autoformat fields and exta validation
April 06, 2008, 06:53:13 am
Hello,

To keep the contact database coherent, I'd like to add automatic formats. For instance, all the first names should start with a capital letter, and if I create a "XAVIER", it should be formated as "Xavier".

I thought doing that by creating a custom template, and adding a bit of js in it, but I feel that's going to be a pain to maintain. How do you do it ? Any suggestion more than welcome.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Autoformat fields and exta validation
April 06, 2008, 08:37:05 am
Not sure about auto-formatting, but you can use the Validate Hook to add custom validation logic to form fields:

http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+hook+specification
Protect your investment in CiviCRM by  becoming a Member!

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Autoformat fields and exta validation
April 06, 2008, 11:38:06 am

The auto formatting can be potentially done in the "pre" hook for contact create, where the POST params are passed to the pre hook by reference

The pre hook has not been used widely, so this experiment might trigger a few more bugs :)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Autoformat fields and exta validation

This forum was archived on 2017-11-26.