1

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:

$form->addField('legal_identifier');

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.

0

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 Dec 1 '16 at 12:35
1

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, privacy policy and cookie policy

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