From 5628bc2c9ba82570c63d491e1ee8ae7de6494508 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Tue, 18 May 2010 18:30:49 +0000 Subject: - Patch #680416 by Amitaibu, yched: allow defining fields that can not be added via UI. --- modules/field/field.api.php | 4 ++++ modules/field/tests/field_test.field.inc | 13 +++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'modules/field') diff --git a/modules/field/field.api.php b/modules/field/field.api.php index e37254a16..bc4e26690 100644 --- a/modules/field/field.api.php +++ b/modules/field/field.api.php @@ -149,6 +149,10 @@ function hook_field_extra_fields_alter(&$info) { * instance definition. This formatter must be available whenever the field * type is available (i.e. provided by the field type module, or by a module * the field type module depends on). + * - no_ui: (optional) A boolean specifying that users should not be allowed + * to create fields and instances of this field type through the UI. Such + * fields can only be created programmatically with field_create_field() + * and field_create_instance(). Defaults to FALSE. * * @see hook_field_info_alter() */ diff --git a/modules/field/tests/field_test.field.inc b/modules/field/tests/field_test.field.inc index faf1b1469..116e94a6a 100644 --- a/modules/field/tests/field_test.field.inc +++ b/modules/field/tests/field_test.field.inc @@ -12,7 +12,7 @@ function field_test_field_info() { return array( 'test_field' => array( - 'label' => t('Test Field'), + 'label' => t('Test field'), 'description' => t('Dummy field type used for tests.'), 'settings' => array( 'test_field_setting' => 'dummy test string', @@ -26,6 +26,15 @@ function field_test_field_info() { 'default_widget' => 'test_field_widget', 'default_formatter' => 'field_test_default', ), + 'hidden_test_field' => array( + 'no_ui' => TRUE, + 'label' => t('Hidden from UI test field'), + 'description' => t('Dummy hidden field type used for tests.'), + 'settings' => array(), + 'instance_settings' => array(), + 'default_widget' => 'test_field_widget', + 'default_formatter' => 'field_test_default', + ), ); } @@ -139,7 +148,7 @@ function field_test_field_widget_info() { return array( 'test_field_widget' => array( 'label' => t('Test field'), - 'field types' => array('test_field'), + 'field types' => array('test_field', 'hidden_test_field'), 'settings' => array('test_widget_setting' => 'dummy test string'), ), 'test_field_widget_multiple' => array( -- cgit v1.2.3