diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index 619dbdb042af..6472813b53ab 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -1132,6 +1132,10 @@ public static function addQuickFormElement( $qf->assign('customUrls', $customUrls); break; + + case 'Hidden': + $element = $qf->add('hidden', $elementName); + break; } switch ($field->data_type) { @@ -2221,7 +2225,7 @@ protected static function prepareCreate($params) { // 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. diff --git a/CRM/Core/SelectValues.php b/CRM/Core/SelectValues.php index 452e4b2556d9..1eadb3f5beab 100644 --- a/CRM/Core/SelectValues.php +++ b/CRM/Core/SelectValues.php @@ -219,6 +219,11 @@ public static function customHtmlType() { 'name' => 'Link', 'label' => ts('Link'), ], + [ + 'id' => 'Hidden', + 'name' => 'Hidden', + 'label' => ts('Hidden'), + ], ]; } diff --git a/CRM/Custom/Form/Field.php b/CRM/Custom/Form/Field.php index 9a8c2e3d7362..ece46e555556 100644 --- a/CRM/Custom/Form/Field.php +++ b/CRM/Custom/Form/Field.php @@ -58,10 +58,10 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { * @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'], diff --git a/CRM/Custom/Page/Field.php b/CRM/Custom/Page/Field.php index 8d6b6aefb653..188e48ed4d14 100644 --- a/CRM/Custom/Page/Field.php +++ b/CRM/Custom/Page/Field.php @@ -133,27 +133,9 @@ public function browse() { $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'); diff --git a/Civi/Api4/Generic/BasicGetFieldsAction.php b/Civi/Api4/Generic/BasicGetFieldsAction.php index 2dc62f8cb082..07ba072000fb 100644 --- a/Civi/Api4/Generic/BasicGetFieldsAction.php +++ b/Civi/Api4/Generic/BasicGetFieldsAction.php @@ -325,6 +325,7 @@ public function fields() { 'Email' => ts('Email'), 'EntityRef' => ts('Autocomplete Entity'), 'File' => ts('File'), + 'Hidden' => ts('Hidden'), 'Location' => ts('Address Location'), 'Number' => ts('Number'), 'Radio' => ts('Radio Buttons'), diff --git a/ext/afform/admin/ang/afGuiEditor/elements/afGuiField.component.js b/ext/afform/admin/ang/afGuiEditor/elements/afGuiField.component.js index 8772532e281a..1b9f03495dbe 100644 --- a/ext/afform/admin/ang/afGuiEditor/elements/afGuiField.component.js +++ b/ext/afform/admin/ang/afGuiEditor/elements/afGuiField.component.js @@ -181,6 +181,7 @@ return !(defn.options || defn.data_type === 'Boolean'); case 'DisplayOnly': + case 'Hidden': return true; default: diff --git a/ext/afform/admin/ang/afGuiEditor/inputType/Hidden.html b/ext/afform/admin/ang/afGuiEditor/inputType/Hidden.html new file mode 100644 index 000000000000..c19e65aec0fc --- /dev/null +++ b/ext/afform/admin/ang/afGuiEditor/inputType/Hidden.html @@ -0,0 +1 @@ +
diff --git a/ext/afform/core/ang/af/fields/Hidden.html b/ext/afform/core/ang/af/fields/Hidden.html new file mode 100644 index 000000000000..3a274235c055 --- /dev/null +++ b/ext/afform/core/ang/af/fields/Hidden.html @@ -0,0 +1 @@ + diff --git a/templates/CRM/Custom/Form/Edit/CustomField.tpl b/templates/CRM/Custom/Form/Edit/CustomField.tpl index 24f0e5b7f44f..34dd650732ff 100644 --- a/templates/CRM/Custom/Form/Edit/CustomField.tpl +++ b/templates/CRM/Custom/Form/Edit/CustomField.tpl @@ -14,7 +14,12 @@