I tried add legal_identifier field by custom tempelate. It worked for pages, but not for forms. Then I added this code to sites/all/modules/civicrm/CRM/Contact/Form/Edit/Organization.php:


Now it works good in organization contacts, but I'm not shure if this is correct. Can I edit this file? What will happen after update? Is there some better way? Can I use some hook? How? Thank's, I'm getting started with civiCRM.

2 Answers 2


There are a number of strategies for customizing CiviCRM! They have their advantages and disadvantages - but you should definitely be concerned about your change disappearing on upgrade.

The easiest change is to use a custom PHP page just like a custom template. Details are available on this wiki page. However, this is rarely a maintainable solution, because you'll need to compare your file to the original every time you upgrade and move your changes over.

A better solution is to create an extension and use a hook. The correct hook here is hook_civicrm_buildForm. I would insert a simple conditional to check that the $formName is the one you want to operate on, and if so to add your one line of code. This is far more maintainable.

Please join us at http://chat.civicrm.org in the #dev-newcomers channel and we'll be happy to help get you set up with civix or any other tools you need to create extensions!

  • Thank's, I used custom php. Create an extension is challenge. Maybe next time...
    – mekke
    Commented Dec 1, 2016 at 12:35

Why not simply a civicrm custom field, that you could use in a Profile or a Webform (if you are based upon Drupal) ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.