diff options
Diffstat (limited to 'modules/field')
-rw-r--r-- | modules/field/field.api.php | 20 | ||||
-rw-r--r-- | modules/field/field.form.inc | 35 | ||||
-rw-r--r-- | modules/field/field.info.inc | 9 | ||||
-rw-r--r-- | modules/field/field.install | 10 | ||||
-rw-r--r-- | modules/field/field.module | 2 | ||||
-rw-r--r-- | modules/field/modules/field_sql_storage/field_sql_storage.install | 2 | ||||
-rw-r--r-- | modules/field/theme/field.tpl.php | 2 |
7 files changed, 62 insertions, 18 deletions
diff --git a/modules/field/field.api.php b/modules/field/field.api.php index 0d01c59fa..5f641173e 100644 --- a/modules/field/field.api.php +++ b/modules/field/field.api.php @@ -690,11 +690,10 @@ function hook_field_is_empty($item, $field) { * which widget to use. Widget types are defined by implementing * hook_field_widget_info(). * - * Widgets are - * @link http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html Form API @endlink - * elements with additional processing capabilities. Widget hooks are typically - * called by the Field Attach API during the creation of the field form - * structure with field_attach_form(). + * Widgets are @link forms_api_reference.html Form API @endlink elements with + * additional processing capabilities. Widget hooks are typically called by the + * Field Attach API during the creation of the field form structure with + * field_attach_form(). * * @see field * @see field_types @@ -729,6 +728,9 @@ function hook_field_is_empty($item, $field) { * - FIELD_BEHAVIOR_DEFAULT: (default) If the widget accepts default * values. * - FIELD_BEHAVIOR_NONE: if the widget does not support default values. + * - weight: (optional) An integer to determine the weight of this widget + * relative to other widgets in the Field UI when selecting a widget for a + * given field instance. * * @see hook_field_widget_info_alter() * @see hook_field_widget_form() @@ -738,7 +740,7 @@ function hook_field_is_empty($item, $field) { * @see hook_field_widget_settings_form() */ function hook_field_widget_info() { - return array( + return array( 'text_textfield' => array( 'label' => t('Text field'), 'field types' => array('text'), @@ -765,6 +767,8 @@ function hook_field_widget_info() { 'multiple values' => FIELD_BEHAVIOR_DEFAULT, 'default value' => FIELD_BEHAVIOR_DEFAULT, ), + // As an advanced widget, force it to sink to the bottom of the choices. + 'weight' => 2, ), ); } @@ -1072,8 +1076,8 @@ function hook_field_formatter_info() { * Perform alterations on Field API formatter types. * * @param $info - * Array of informations on formatter types exposed by - * hook_field_field_formatter_info() implementations. + * An array of information on formatter types exposed by + * hook_field_formatter_info() implementations. */ function hook_field_formatter_info_alter(&$info) { // Add a setting to a formatter type. diff --git a/modules/field/field.form.inc b/modules/field/field.form.inc index 6c27c4329..280f778ff 100644 --- a/modules/field/field.form.inc +++ b/modules/field/field.form.inc @@ -6,7 +6,38 @@ */ /** - * Create a separate form element for each field. + * Creates a form element for a field and can populate it with a default value. + * + * If the form element is not associated with an entity (i.e., $entity is NULL) + * field_get_default_value will be called to supply the default value for the + * field. Also allows other modules to alter the form element by implementing + * their own hooks. + * + * @param $entity_type + * The type of entity (for example 'node' or 'user') that the field belongs + * to. + * @param $entity + * The entity object that the field belongs to. This may be NULL if creating a + * form element with a default value. + * @param $field + * An array representing the field whose editing element is being created. + * @param $instance + * An array representing the structure for $field in its current context. + * @param $langcode + * The language associated with the field. + * @param $items + * An array of the field values. When creating a new entity this may be NULL + * or an empty array to use default values. + * @param $form + * An array representing the form that the editing element will be attached + * to. + * @param $form_state + * An array containing the current state of the form. + * @param $get_delta + * Used to get only a specific delta value of a multiple value field. + * + * @return + * The form element array created for this field. */ function field_default_form($entity_type, $entity, $field, $instance, $langcode, $items, &$form, &$form_state, $get_delta = NULL) { // This could be called with no entity, as when a UI module creates a @@ -278,7 +309,7 @@ function theme_field_multiple_value_form($variables) { $header = array( array( - 'data' => '<label>' . t('!title: !required', array('!title' => $element['#title'], '!required' => $required)) . "</label>", + 'data' => '<label>' . t('!title !required', array('!title' => $element['#title'], '!required' => $required)) . "</label>", 'colspan' => 2, 'class' => array('field-label'), ), diff --git a/modules/field/field.info.inc b/modules/field/field.info.inc index eb5cc5ca7..9e7ab938d 100644 --- a/modules/field/field.info.inc +++ b/modules/field/field.info.inc @@ -54,8 +54,8 @@ function field_info_cache_clear() { * the field type. * - 'widget types': Array of hook_field_widget_info() results, keyed by * widget_type. Each element has the following components: label, field - * types, settings, and behaviors from hook_field_widget_info(), as well - * as module, giving the module that exposes the widget type. + * types, settings, weight, and behaviors from hook_field_widget_info(), + * as well as module, giving the module that exposes the widget type. * - 'formatter types': Array of hook_field_formatter_info() results, keyed by * formatter_type. Each element has the following components: label, field * types, and behaviors from hook_field_formatter_info(), as well as @@ -124,6 +124,7 @@ function _field_info_collate_types($reset = FALSE) { } } drupal_alter('field_widget_info', $info['widget types']); + uasort($info['widget types'], 'drupal_sort_weight'); // Populate formatter types. foreach (module_implements('field_formatter_info') as $module) { @@ -702,6 +703,10 @@ function field_info_instances($entity_type = NULL, $bundle_name = NULL) { * The field name for the instance. * @param $bundle_name * The bundle name for the instance. + * + * @return + * An associative array of instance data for the specific field and bundle; + * NULL if the instance does not exist. */ function field_info_instance($entity_type, $field_name, $bundle_name) { $info = _field_info_collate_fields(); diff --git a/modules/field/field.install b/modules/field/field.install index 5934a264c..34d28073d 100644 --- a/modules/field/field.install +++ b/modules/field/field.install @@ -172,7 +172,7 @@ function field_schema() { * This function can be used for databases whose schema is at field module * version 7000 or higher. * - * @ingroup update-api-6.x-to-7.x + * @ingroup update_api */ function _update_7000_field_create_field(&$field) { // Merge in default values.` @@ -253,7 +253,7 @@ function _update_7000_field_create_field(&$field) { * @param $field_name * The field name to delete. * - * @ingroup update-api-6.x-to-7.x + * @ingroup update_api */ function _update_7000_field_delete_field($field_name) { $table_name = 'field_data_' . $field_name; @@ -284,7 +284,7 @@ function _update_7000_field_delete_field($field_name) { * * This function is valid for a database schema version 7000. * - * @ingroup update-api-6.x-to-7.x + * @ingroup update_api */ function _update_7000_field_delete_instance($field_name, $entity_type, $bundle) { // Delete field instance configuration data. @@ -322,6 +322,8 @@ function _update_7000_field_delete_instance($field_name, $entity_type, $bundle) * @return * An array of fields matching $conditions, keyed by the property specified * by the $key parameter. + * + * @ingroup update_api */ function _update_7000_field_read_fields(array $conditions = array(), $key = 'id') { $fields = array(); @@ -356,7 +358,7 @@ function _update_7000_field_read_fields(array $conditions = array(), $key = 'id' * This function can be used for databases whose schema is at field module * version 7000 or higher. * - * @ingroup update-api-6.x-to-7.x + * @ingroup update_api */ function _update_7000_field_create_instance($field, &$instance) { // Merge in defaults. diff --git a/modules/field/field.module b/modules/field/field.module index 6fc97a2bf..b6cf05c9b 100644 --- a/modules/field/field.module +++ b/modules/field/field.module @@ -376,7 +376,7 @@ function field_system_info_alter(&$info, $file, $type) { } if ($non_deleted) { if (module_exists('field_ui')) { - $explanation = t('Field type(s) in use - see !link', array('!link' => l(t('Field list'), 'admin/reports/fields'))); + $explanation = t('Field type(s) in use - see <a href="@fields-page">Field list</a>', array('@fields-page' => url('admin/reports/fields'))); } else { $explanation = t('Fields type(s) in use'); diff --git a/modules/field/modules/field_sql_storage/field_sql_storage.install b/modules/field/modules/field_sql_storage/field_sql_storage.install index 78c520fcf..24973ab45 100644 --- a/modules/field/modules/field_sql_storage/field_sql_storage.install +++ b/modules/field/modules/field_sql_storage/field_sql_storage.install @@ -30,7 +30,7 @@ function field_sql_storage_schema() { * This function can be used for databases whose schema is at field module * version 7000 or higher. * - * @ingroup update-api-6.x-to-7.x + * @ingroup update_api */ function _update_7000_field_sql_storage_write($entity_type, $bundle, $entity_id, $revision_id, $field_name, $data) { $table_name = "field_data_{$field_name}"; diff --git a/modules/field/theme/field.tpl.php b/modules/field/theme/field.tpl.php index a6d7a9659..f0f9d583f 100644 --- a/modules/field/theme/field.tpl.php +++ b/modules/field/theme/field.tpl.php @@ -40,6 +40,8 @@ * * @see template_preprocess_field() * @see theme_field() + * + * @ingroup themeable */ ?> <!-- |