0

I want to force a default value for the field priority in the actions form, so that users don't have to pick the right value if the default value is OK.

2

Bernard, you can do this by developing a little extension and using the buildForm hook to set the default value of the priority. In the buildForm hook you can do something like this:

if ($form->_action == CRM_Core_Action::ADD) {
  try {
    $normaal = (int) civicrm_api3('OptionValue', 'getvalue', [
       'return' => "value",
       'option_group_id' => "priority",
       'name' => "Normal",
    ]);
    $defaults['priority_id'] = $normaal;
    $form->setDefaults($defaults);
  }
  catch (CiviCRM_API3_Exception $ex) {
    Civi::log()->warning(E::ts('Onverwachte fout: geen prioriteit met naam Normal gevonden in ') . __METHOD__ . E::ts(', foutmelding van API OptionValue getvalue: ') . $ex->getMessage());

} }

More information on the buildForm can be found here: https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_buildForm/

Does this make sense?

| improve this answer | |

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.