$qf->assign('customUrls', $customUrls);
break;
+
+ case 'Hidden':
+ $element = $qf->add('hidden', $elementName);
+ break;
}
switch ($field->data_type) {
// create any option group & values if required
$allowedOptionTypes = ['String', 'Int', 'Float', 'Money'];
- if ($htmlType !== 'Text' && in_array($dataType, $allowedOptionTypes, TRUE)) {
+ if (!in_array($htmlType, ['Text', 'Hidden'], TRUE) && in_array($dataType, $allowedOptionTypes, TRUE)) {
//CRM-16659: if option_value then create an option group for this custom field.
// An option_type of 2 would be a 'message' from the form layer not to handle
// the option_values key. If not set then it is not ignored.
'name' => 'Link',
'label' => ts('Link'),
],
+ [
+ 'id' => 'Hidden',
+ 'name' => 'Hidden',
+ 'label' => ts('Hidden'),
+ ],
];
}
* @var array[]
*/
public static $_dataToHTML = [
- 'String' => ['Text', 'Select', 'Radio', 'CheckBox', 'Autocomplete-Select'],
- 'Int' => ['Text', 'Select', 'Radio'],
- 'Float' => ['Text', 'Select', 'Radio'],
- 'Money' => ['Text', 'Select', 'Radio'],
+ 'String' => ['Text', 'Select', 'Radio', 'CheckBox', 'Autocomplete-Select', 'Hidden'],
+ 'Int' => ['Text', 'Select', 'Radio', 'Hidden'],
+ 'Float' => ['Text', 'Select', 'Radio', 'Hidden'],
+ 'Money' => ['Text', 'Select', 'Radio', 'Hidden'],
'Memo' => ['TextArea', 'RichTextEditor'],
'Date' => ['Select Date'],
'Boolean' => ['Radio'],
$action -= CRM_Core_Action::DISABLE;
}
- switch ($customFieldBAO->data_type) {
- case "String":
- case "Int":
- case "Float":
- case "Money":
- // if Multi Select field is selected in custom field
- if ($customFieldBAO->html_type == 'Text') {
- $action -= CRM_Core_Action::BROWSE;
- }
- break;
-
- case "ContactReference":
- case "Memo":
- case "Date":
- case "Boolean":
- case "StateProvince":
- case "Country":
- case "File":
- case "Link":
- $action -= CRM_Core_Action::BROWSE;
- break;
+ // Remove link to edit option group if there isn't one
+ if (!$customFieldBAO->option_group_id) {
+ $action -= CRM_Core_Action::BROWSE;
}
$customFieldDataType = array_column(CRM_Core_BAO_CustomField::dataType(), 'label', 'id');
'Email' => ts('Email'),
'EntityRef' => ts('Autocomplete Entity'),
'File' => ts('File'),
+ 'Hidden' => ts('Hidden'),
'Location' => ts('Address Location'),
'Number' => ts('Number'),
'Radio' => ts('Radio Buttons'),
return !(defn.options || defn.data_type === 'Boolean');
case 'DisplayOnly':
+ case 'Hidden':
return true;
default:
--- /dev/null
+<div class="form-inline"></div>
--- /dev/null
+<input type="hidden" id="{{:: fieldId }}" ng-model="getSetValue" ng-model-options="{getterSetter: true}" >
<td class="html-adjust description">{$element.help_pre}</td>
</tr>
{/if}
-{if $element.options_per_line}
+{if $element.html_type === 'Hidden'}
+ {* Hidden field - render in hidden row *}
+ <tr class="custom_field-row {$element.element_name}-row hiddenElement">
+ <td>{$formElement.html}</td>
+ </tr>
+{elseif $element.options_per_line}
<tr class="custom_field-row {$element.element_name}-row">
<td class="label">{$formElement.label}{if $element.help_post}{help id=$element.id file="CRM/Custom/Form/CustomField.hlp" title=$element.label}{/if}</td>
<td class="html-adjust">
}
if (_.includes(['String', 'Int', 'Float', 'Money'], dataType)) {
- if (htmlType !== "Text") {
+ if (!['Text', 'Hidden'].includes(htmlType)) {
$("#showoption, #searchable", $form).show();
$("#hideDefault, #hideDesc, #searchByRange", $form).hide();
} else {
$("#showoption").hide();
}
- if (_.includes(['String', 'Int', 'Float', 'Money'], dataType) && htmlType !== 'Text') {
+ if (_.includes(['String', 'Int', 'Float', 'Money'], dataType) && !['Text', 'Hidden'].includes(htmlType)) {
if (serialize) {
$('div[id^=checkbox]', '#optionField').show();
$('div[id^=radio]', '#optionField').hide();
->execute();
}
- public function testDisabledFields(): void {
+ public function testDisabledAndHiddenFields(): void {
// Create a custom group with one enabled and one disabled field
CustomGroup::create(FALSE)
->addValue('extends', 'Activity')
'records' => [
['label' => 'enabled_field'],
['label' => 'disabled_field', 'is_active' => FALSE],
+ ['label' => 'hidden_field', 'html_type' => 'Hidden'],
],
'defaults' => ['custom_group_id.name' => 'act_test_grp'],
]);
- // Only the enabled field shows up
- $getFields = Activity::getFields(FALSE)->execute()->column('name');
- $this->assertContains('act_test_grp.enabled_field', $getFields);
- $this->assertNotContains('act_test_grp.disabled_field', $getFields);
+ // Only the enabled fields show up
+ $getFields = Activity::getFields(FALSE)->execute()->indexBy('name');
+ $this->assertArrayHasKey('act_test_grp.enabled_field', $getFields);
+ $this->assertArrayHasKey('act_test_grp.hidden_field', $getFields);
+ $this->assertArrayNotHasKey('act_test_grp.disabled_field', $getFields);
+
+ // Hidden field does not have option lists
+ $this->assertFalse($getFields['act_test_grp.hidden_field']['options']);
+ $this->assertNull($getFields['act_test_grp.hidden_field']['suffixes']);
// Disable the entire custom group
CustomGroup::update(FALSE)