本文整理汇总了PHP中CRM_Core_BAO_OptionValue::getOptionValuesArray方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_OptionValue::getOptionValuesArray方法的具体用法?PHP CRM_Core_BAO_OptionValue::getOptionValuesArray怎么用?PHP CRM_Core_BAO_OptionValue::getOptionValuesArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_OptionValue
的用法示例。
在下文中一共展示了CRM_Core_BAO_OptionValue::getOptionValuesArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkOptionGroupValues
/**
* @return array
*/
public function checkOptionGroupValues()
{
$messages = array();
$problemValues = array();
$optionGroups = civicrm_api3('OptionGroup', 'get', array('sequential' => 1, 'data_type' => array('IS NOT NULL' => 1), 'options' => array('limit' => 0)));
if ($optionGroups['count'] > 0) {
foreach ($optionGroups['values'] as $optionGroup) {
$values = CRM_Core_BAO_OptionValue::getOptionValuesArray($optionGroup['id']);
if (count($values) > 0) {
foreach ($values as $value) {
$validate = CRM_Utils_Type::validate($value['value'], $optionGroup['data_type'], FALSE);
if (!$validate) {
$problemValues[] = array('group_name' => $optionGroup['title'], 'value_name' => $value['label']);
}
}
}
}
}
if (!empty($problemValues)) {
$strings = '';
foreach ($problemValues as $problemValue) {
$strings .= ts('<tr><td> "%1" </td><td> "%2" </td></tr>', array(1 => $problemValue['group_name'], 2 => $problemValue['value_name']));
}
$messages[] = new CRM_Utils_Check_Message(__FUNCTION__, ts('The Following Option Values contain value fields that do not match the Data Type of the Option Group</p>
<p><table><tbody><th>Option Group</th><th>Option Value</th></tbody><tbody>') . $strings . ts('</tbody></table></p>'), ts('Option Values with problematic Values'), \Psr\Log\LogLevel::NOTICE, 'fa-server');
}
return $messages;
}
示例2: getCustomOption
/**
* Returns all active options ordered by weight for a given field
*
* @param int $fieldId field whose options are needed
* @param boolean $inactiveNeeded do we need inactive options ?
*
* @return array $customOption all active options for fieldId
* @static
*/
static function getCustomOption($fieldID, $inactiveNeeded = FALSE)
{
$options = array();
if (!$fieldID) {
return $options;
}
$field = CRM_Core_BAO_CustomField::getFieldObject($fieldID);
// get the option group id
$optionGroupID = $field->option_group_id;
if (!$optionGroupID) {
return $options;
}
$optionValues = CRM_Core_BAO_OptionValue::getOptionValuesArray($optionGroupID);
foreach ($optionValues as $id => $value) {
if (!$inactiveNeeded && empty($value['is_active'])) {
continue;
}
$options[$id] = array();
$options[$id]['id'] = $id;
$options[$id]['label'] = $value['label'];
$options[$id]['value'] = $value['value'];
}
CRM_Utils_Hook::customFieldOptions($fieldID, $options, TRUE);
return $options;
}
示例3: buildQuickForm
function buildQuickForm()
{
$this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
$optionGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'hrjc_hours_type', 'id', 'name');
$optionGroupIds = CRM_Core_BAO_OptionValue::getOptionValuesArray($optionGroupId);
foreach ($optionGroupIds as $key => $value) {
$this->_optionValue[$value['value']] = $value['label'];
$this->_id[$key] = $value['value'];
}
$this->assign('optionGroupIds', $optionGroupIds);
$this->addElement('select', 'hour_type_select', ts('Select Hour Type'), array('' => ts('- select -')) + $this->_optionValue);
$this->add('text', 'hour_value', ts('Value'));
$this->addFormRule(array('CRM_Hrjobcontract_Form_EditHourOption', 'formRule'), $this);
}