CRM_Core_Error::fatal("You cannot add or edit muliple choice options in a reserved custom field-set.");
}
+ $optionGroupId = $this->getOptionGroupId($this->_fid);
+ $isOptionGroupLocked = $optionGroupId ? $this->isOptionGroupLocked($optionGroupId) : FALSE;
+ $this->assign('optionGroupId', $optionGroupId);
+ $this->assign('isOptionGroupLocked', $isOptionGroupLocked);
+
//as url contain $gid so append breadcrumb dynamically.
$breadcrumb = array(
array(
return parent::run();
}
+ /**
+ * Gets the "is_locked" status for the provided option group
+ *
+ * @param int $optionGroupId
+ *
+ * @return bool
+ */
+ private function isOptionGroupLocked($optionGroupId) {
+ return (bool) CRM_Core_DAO::getFieldValue(
+ CRM_Core_DAO_OptionGroup::class,
+ $optionGroupId,
+ 'is_locked'
+ );
+ }
+
+ /**
+ * Gets the associated "option_group_id" for a custom field
+ *
+ * @param int $customFieldId
+ *
+ * @return int
+ */
+ private function getOptionGroupId($customFieldId) {
+ return (int) CRM_Core_DAO::getFieldValue(
+ CRM_Core_DAO_CustomField::class,
+ $customFieldId,
+ 'option_group_id'
+ );
+ }
+
}
<div class="action-link">
{crmButton q="reset=1&action=map&fid=$fid&gid=$gid" class="action-item open-inline-noreturn" icon="sort-alpha-asc"}{ts}Alphabetize Options{/ts}{/crmButton}
- {crmButton q="reset=1&action=add&fid=$fid&gid=$gid" class="action-item" icon="plus-circle"}{ts}Add Option{/ts}{/crmButton}
+ {if !$isOptionGroupLocked}
+ {crmButton q="reset=1&action=add&fid=$fid&gid=$gid" class="action-item" icon="plus-circle"}{ts}Add Option{/ts}{/crmButton}
+ {/if}
{crmButton p="civicrm/admin/custom/group/field" q="reset=1&action=browse&gid=$gid" class="action-item cancel" icon="times"}{ts}Done{/ts}{/crmButton}
</div>
</div>