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) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Setting communication language as a 'required' field
Pages: [1]

Author Topic: Setting communication language as a 'required' field  (Read 344 times)

vchryssos

  • I’m new here
  • *
  • Posts: 5
  • Karma: 0
    • FOSS OFFICE
  • CiviCRM version: 4.5.3
  • CMS version: Joomla
  • MySQL version: 5.5.40-0+wheezy1
  • PHP version: 5.4.34-0+deb7u1
Setting communication language as a 'required' field
February 11, 2015, 07:13:58 am
How can I set the 'Language' field under  'Communication preferences' tab as a required field?

Alternatively, how can I set a default value for it?
(I don't want that default value to mess with the whole of the CiviCRM environment, though, as in Administrater|Localization|Languages)

Thnx in advance!

joanne

  • Administrator
  • Ask me questions
  • *****
  • Posts: 852
  • Karma: 83
  • CiviCRM version: 4.4.16
  • CMS version: Drupal 7
Re: Setting communication language as a 'required' field
February 11, 2015, 03:14:25 pm
You could do this by creating a profile for back office users to fill in when they create a new user.

Refer to Making custom data entry forms in  http://book.civicrm.org/user/current/initial-set-up/customizing-the-user-interface/  for info on how to do that
 and Customizing the navigation menu  in the same chapter for how to include it at in the Contacts menu.





JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Re: Setting communication language as a 'required' field
February 11, 2015, 03:34:57 pm
Joanne's approach is a good one.  If you need to keep the existing entry forms, but just need to make a field required, you need a little bit of custom code.  The best way to do this is by making an extension - use "hook_civicrm_buildForm".  I made the "Contribution Page" field required when entering a contribution from the back end with this code:

Code: [Select]
function backenddonations_civicrm_buildForm( $formName, &$form) {
  if($formName == CRM_Contribute_Form_Contribution) {
    //make Contribution Page ID required.
    //but this hook gets called for all the subsections of this page, so only call it when applicable.
    if(array_key_exists('contribution_page_id',$form->_elementIndex)) {
      $form->addRule('contribution_page_id', ts('Contribution Page name is required.'), 'required');
    }
  }
}
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Setting communication language as a 'required' field

This forum was archived on 2017-11-26.