Index: modules/comment/comment.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.install,v
retrieving revision 1.66
diff -u -9 -p -r1.66 comment.install
--- modules/comment/comment.install	17 Apr 2010 12:54:02 -0000	1.66
+++ modules/comment/comment.install	29 Apr 2010 21:42:41 -0000
@@ -272,19 +272,19 @@ function comment_update_7012() {
     'entity_types' => array('comment'),
   );
   field_create_field($field);
 
   // Add the field to comments for all existing bundles.
   $body_instance = array(
     'field_name' => 'comment_body',
     'label' => 'Comment',
     'entity_type' => 'comment',
-    'settings' => array('text_processing' => 1),
+    'settings' => array('format' => ''),
     // Hide field label by default.
     'display' => array(
       'full' => array(
         'label' => 'hidden',
       ),
     ),
   );
   foreach (node_type_get_types() as $info) {
     $body_instance['bundle'] = 'comment_node_' . $info->type;
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.872
diff -u -9 -p -r1.872 comment.module
--- modules/comment/comment.module	28 Apr 2010 16:08:51 -0000	1.872
+++ modules/comment/comment.module	29 Apr 2010 21:42:42 -0000
@@ -354,19 +354,19 @@ function comment_node_type_delete($info)
  * type.
  */
 function _comment_body_field_instance_create($info) {
   // Attaches the body field by default.
   $instance = array(
     'field_name' => 'comment_body',
     'label' => 'Comment',
     'entity_type' => 'comment',
     'bundle' => 'comment_node_' . $info->type,
-    'settings' => array('text_processing' => 1),
+    'settings' => array('format' => ''),
     'required' => TRUE,
     // Hides field label by default.
     'display' => array(
       'full' => array(
         'label' => 'hidden',
       ),
     ),
   );
   field_create_instance($instance);
Index: modules/field/field.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.api.php,v
retrieving revision 1.75
diff -u -9 -p -r1.75 field.api.php
--- modules/field/field.api.php	24 Apr 2010 07:19:09 -0000	1.75
+++ modules/field/field.api.php	29 Apr 2010 21:42:42 -0000
@@ -149,35 +149,35 @@ function hook_field_extra_fields_alter(&
  *     type is available (i.e. provided by the field type module, or by a module
  *     the field type module depends on).
  */
 function hook_field_info() {
   return array(
     'text' => array(
       'label' => t('Text'),
       'description' => t('This field stores varchar text in the database.'),
       'settings' => array('max_length' => 255),
-      'instance_settings' => array('text_processing' => 0),
+      'instance_settings' => array('format' => filter_fallback_format()),
       'default_widget' => 'text_textfield',
       'default_formatter' => 'text_default',
     ),
     'text_long' => array(
       'label' => t('Long text'),
       'description' => t('This field stores long text in the database.'),
       'settings' => array('max_length' => ''),
-      'instance_settings' => array('text_processing' => 0),
+      'instance_settings' => array('format' => filter_fallback_format()),
       'default_widget' => 'text_textarea',
       'default_formatter' => 'text_default',
     ),
     'text_with_summary' => array(
       'label' => t('Long text and summary'),
       'description' => t('This field stores long text in the database along with optional summary text.'),
       'settings' => array('max_length' => ''),
-      'instance_settings' => array('text_processing' => 1, 'display_summary' => 0),
+      'instance_settings' => array('format' => '', 'display_summary' => 0),
       'default_widget' => 'text_textarea_with_summary',
       'default_formatter' => 'text_summary_or_trimmed',
     ),
   );
 }
 
 /**
  * Perform alterations on Field API field types.
  *
@@ -291,19 +291,19 @@ function hook_field_schema($field) {
  *   parameter by reference.
  */
 function hook_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
   // Sample code from text.module: precompute sanitized strings so they are
   // stored in the field cache.
   foreach ($entities as $id => $entity) {
     foreach ($items[$id] as $delta => $item) {
       // Only process items with a cacheable format, the rest will be handled
       // by formatters if needed.
-      if (empty($instances[$id]['settings']['text_processing']) || filter_format_allowcache($item['format'])) {
+      if (filter_format_allowcache($item['format'])) {
         $items[$id][$delta]['safe_value'] = isset($item['value']) ? _text_sanitize($instances[$id], $langcode, $item, 'value') : '';
         if ($field['type'] == 'text_with_summary') {
           $items[$id][$delta]['safe_summary'] = isset($item['summary']) ? _text_sanitize($instances[$id], $langcode, $item, 'summary') : '';
         }
       }
     }
   }
 }
 
Index: modules/field/modules/text/text.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/text/text.module,v
retrieving revision 1.53
diff -u -9 -p -r1.53 text.module
--- modules/field/modules/text/text.module	13 Apr 2010 15:16:27 -0000	1.53
+++ modules/field/modules/text/text.module	29 Apr 2010 21:42:42 -0000
@@ -19,46 +19,47 @@ function text_help($path, $arg) {
   }
 }
 
 /**
  * Implements hook_field_info().
  *
  * Field settings:
  *   - max_length: the maximum length for a varchar field.
  * Instance settings:
- *   - text_processing: whether text input filters should be used.
+ *   - format: a text format enforced on the field. When empty, the user may
+ *     select the text format.
  *   - display_summary: whether the summary field should be displayed.
  *     When empty and not displayed the summary will take its value from the
  *     trimmed value of the main text field.
  */
 function text_field_info() {
   return array(
     'text' => array(
       'label' => t('Text'),
       'description' => t('This field stores varchar text in the database.'),
       'settings' => array('max_length' => 255),
-      'instance_settings' => array('text_processing' => 0),
+      'instance_settings' => array('format' => filter_fallback_format()),
       'default_widget' => 'text_textfield',
       'default_formatter' => 'text_default',
     ),
     'text_long' => array(
       'label' => t('Long text'),
       'description' => t('This field stores long text in the database.'),
       'settings' => array('max_length' => ''),
-      'instance_settings' => array('text_processing' => 0),
+      'instance_settings' => array('format' => filter_fallback_format()),
       'default_widget' => 'text_textarea',
       'default_formatter' => 'text_default',
     ),
     'text_with_summary' => array(
       'label' => t('Long text and summary'),
       'description' => t('This field stores long text in the database along with optional summary text.'),
       'settings' => array('max_length' => ''),
-      'instance_settings' => array('text_processing' => 1, 'display_summary' => 0),
+      'instance_settings' => array('format' => '', 'display_summary' => 0),
       'default_widget' => 'text_textarea_with_summary',
       'default_formatter' => 'text_summary_or_trimmed',
     ),
   );
 }
 
 /**
  * Implements hook_field_schema().
  */
@@ -131,28 +132,33 @@ function text_field_settings_form($field
   );
 
   return $form;
 }
 
 /**
  * Implements hook_field_instance_settings_form().
  */
 function text_field_instance_settings_form($field, $instance) {
+  global $user;
+
   $settings = $instance['settings'];
 
-  $form['text_processing'] = array(
-    '#type' => 'radios',
-    '#title' => t('Text processing'),
-    '#default_value' => $settings['text_processing'],
-    '#options' => array(
-      t('Plain text'),
-      t('Filtered text (user selects text format)'),
-    ),
+  $formats = filter_formats($user);
+  $options = array('' => t('User selects text format'));
+  foreach ($formats as $format) {
+    $options[$format->format] = $format->name;
+  }
+  $form['format'] = array(
+    '#type' => 'select',
+    '#title' => t('Text format'),
+    '#options' => $options,
+    '#default_value' => $settings['format'],
+    '#attributes' => array('class' => array('filter-list')),
   );
   if ($field['type'] == 'text_with_summary') {
     $form['display_summary'] = array(
       '#type' => 'checkbox',
       '#title' => t('Summary input'),
       '#default_value' => $settings['display_summary'],
       '#description' => t('This allows authors to input an explicit summary, to be displayed instead of the automatically trimmed text when using the "Summary or trimmed" display type.'),
     );
   }
@@ -201,19 +207,19 @@ function text_field_validate($entity_typ
  * separately.
  *
  * @see text_field_formatter_view()
  */
 function text_field_load($entity_type, $entities, $field, $instances, $langcode, &$items) {
   foreach ($entities as $id => $entity) {
     foreach ($items[$id] as $delta => $item) {
       // Only process items with a cacheable format, the rest will be handled
       // by formatters if needed.
-      if (empty($instances[$id]['settings']['text_processing']) || filter_format_allowcache($item['format'])) {
+      if (filter_format_allowcache($item['format'])) {
         $items[$id][$delta]['safe_value'] = isset($item['value']) ? _text_sanitize($instances[$id], $langcode, $item, 'value') : '';
         if ($field['type'] == 'text_with_summary') {
           $items[$id][$delta]['safe_summary'] = isset($item['summary']) ? _text_sanitize($instances[$id], $langcode, $item, 'summary') : '';
         }
       }
     }
   }
 }
 
@@ -268,33 +274,33 @@ function text_field_formatter_info() {
 function text_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
   $element = array();
 
   switch ($display['type']) {
     case 'text_default':
     case 'text_trimmed':
       foreach ($items as $delta => $item) {
         $output = _text_sanitize($instance, $langcode, $item, 'value');
         if ($display['type'] == 'text_trimmed') {
-          $output = text_summary($output, $instance['settings']['text_processing'] ? $item['format'] : NULL);
+          $output = text_summary($output, $item['format']);
         }
         $element[$delta] = array('#markup' => $output);
       }
       break;
 
     case 'text_summary_or_trimmed':
       foreach ($items as $delta => $item) {
         if (!empty($item['summary'])) {
           $output = _text_sanitize($instance, $langcode, $item, 'summary');
         }
         else {
           $output = _text_sanitize($instance, $langcode, $item, 'value');
           $size = variable_get('teaser_length_' . $instance['bundle'], 600);
-          $output = text_summary($output, $instance['settings']['text_processing'] ? $item['format'] : NULL, $size);
+          $output = text_summary($output, $item['format'], $size);
         }
         $element[$delta] = array('#markup' => $output);
       }
       break;
 
     case 'text_plain':
       foreach ($items as $delta => $item) {
         $element[$delta] = array('#markup' => strip_tags($item['value']));
       }
@@ -322,19 +328,19 @@ function text_field_formatter_view($enti
  * @return
  *  The sanitized string.
  */
 function _text_sanitize($instance, $langcode, $item, $column) {
   // If the value uses a cacheable text format, text_field_load() precomputes
   // the sanitized string.
   if (isset($item["safe_$column"])) {
     return $item["safe_$column"];
   }
-  return $instance['settings']['text_processing'] ? check_markup($item[$column], $item['format'], $langcode) : check_plain($item[$column]);
+  return check_markup($item[$column], $item['format'], $langcode);
 }
 
 /**
  * Generate a trimmed, formatted version of a text field value.
  *
  * If the end of the summary is not indicated using the <!--break--> delimiter
  * then we generate the summary automatically, trying to end it at a sensible
  * place such as the end of a paragraph, a line break, or the end of a
  * sentence (in that order of preference).
@@ -549,28 +555,25 @@ function text_field_widget_form(&$form, 
         '#type' => 'textarea',
         '#default_value' => isset($items[$delta]['value']) ? $items[$delta]['value'] : NULL,
         '#rows' => $instance['widget']['settings']['rows'],
         '#attributes' => array('class' => array('text-full')),
       );
       break;
   }
 
   if ($main_widget) {
-    // Conditionally alter the form element's type if text processing is enabled.
-    if ($instance['settings']['text_processing']) {
-      $element = $main_widget;
-      $element['#type'] = 'text_format';
-      $element['#format'] = isset($items[$delta]['format']) ? $items[$delta]['format'] : NULL;
-      $element['#base_type'] = $main_widget['#type'];
-    }
-    else {
-      $element['value'] = $main_widget;
+    $element = $main_widget;
+    $element['#type'] = 'text_format';
+    $element['#format'] = isset($items[$delta]['format']) ? $items[$delta]['format'] : NULL;
+    if ($instance['settings']['format']) {
+      $element['#formats'] = array($instance['settings']['format']);
     }
+    $element['#base_type'] = $main_widget['#type'];
   }
   if ($summary_widget) {
     $element['summary'] = $summary_widget;
   }
 
   return $element;
 }
 
 /**
Index: modules/field/modules/text/text.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/text/text.test,v
retrieving revision 1.22
diff -u -9 -p -r1.22 text.test
--- modules/field/modules/text/text.test	10 Apr 2010 10:01:15 -0000	1.22
+++ modules/field/modules/text/text.test	29 Apr 2010 21:42:42 -0000
@@ -84,19 +84,19 @@ class TextFieldTestCase extends DrupalWe
     $this->field_name = drupal_strtolower($this->randomName());
     $this->field = array('field_name' => $this->field_name, 'type' => $field_type);
     field_create_field($this->field);
     $this->instance = array(
       'field_name' => $this->field_name,
       'entity_type' => 'test_entity',
       'bundle' => 'test_bundle',
       'label' => $this->randomName() . '_label',
       'settings' => array(
-        'text_processing' => TRUE,
+        'format' => '',
       ),
       'widget' => array(
         'type' => $widget_type,
       )
     );
     field_create_instance($this->instance);
     $langcode = LANGUAGE_NONE;
 
     // Display creation form.
@@ -119,38 +119,38 @@ class TextFieldTestCase extends DrupalWe
     $entity->content = field_attach_view($entity_type, $entity);
     $this->content = drupal_render($entity->content);
     $this->assertText($value, 'Filtered tags are not displayed');
   }
 
   /**
    * Test widgets + 'formatted_text' setting.
    */
   function testTextfieldWidgetsFormatted() {
-    $this->_testTextfieldWidgetsFormatted('text', 'text_textfield');
-    $this->_testTextfieldWidgetsFormatted('text_long', 'text_textarea');
+    $this->_testTextfieldWidgetsFormatted('text', 'text_textfield', '');
+    $this->_testTextfieldWidgetsFormatted('text_long', 'text_textarea', filter_fallback_format());
   }
 
   /**
    * Helper function for testTextfieldWidgetsFormatted().
    */
-  function _testTextfieldWidgetsFormatted($field_type, $widget_type) {
+  function _testTextfieldWidgetsFormatted($field_type, $widget_type, $enforce_format) {
     // Setup a field and instance
     $entity_type = 'test_entity';
     $this->field_name = drupal_strtolower($this->randomName());
     $this->field = array('field_name' => $this->field_name, 'type' => $field_type);
     field_create_field($this->field);
     $this->instance = array(
       'field_name' => $this->field_name,
       'entity_type' => 'test_entity',
       'bundle' => 'test_bundle',
       'label' => $this->randomName() . '_label',
       'settings' => array(
-        'text_processing' => TRUE,
+        'format' => $enforce_format,
       ),
       'widget' => array(
         'type' => $widget_type,
       )
     );
     field_create_instance($this->instance);
     $langcode = LANGUAGE_NONE;
 
     // Delete all text formats besides the plain text fallback format.
@@ -193,35 +193,40 @@ class TextFieldTestCase extends DrupalWe
     filter_formats_reset();
     $this->checkPermissions(array(), TRUE);
     $format_id = db_query("SELECT format FROM {filter_format} WHERE name = :name", array(':name' => $edit['name']))->fetchField();
     $permission = filter_permission_name(filter_format_load($format_id));
     $rid = max(array_keys($this->web_user->roles));
     user_role_grant_permissions($rid, array($permission));
     $this->drupalLogin($this->web_user);
 
     // Display edition form.
-    // We should now have a 'text format' selector.
     $this->drupalGet('test-entity/' . $id . '/edit');
     $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', t('Widget is displayed'));
-    $this->assertFieldByName("{$this->field_name}[$langcode][0][format]", '', t('Format selector is displayed'));
-
-    // Edit and change the text format to the new one that was created.
-    $edit = array(
-      "{$this->field_name}[$langcode][0][format]" => $format_id,
-    );
-    $this->drupalPost(NULL, $edit, t('Save'));
-    $this->assertRaw(t('test_entity @id has been updated.', array('@id' => $id)), t('Entity was updated'));
+    $this->assertRaw(t('No HTML tags allowed.'), t('Filter tips are displayed'));
+    if ($enforce_format) {
+      $this->assertNoFieldByName("{$this->field_name}[$langcode][0][format]", '', t('Format selector is not displayed'));
+    }
+    else {
+      $this->assertFieldByName("{$this->field_name}[$langcode][0][format]", '', t('Format selector is displayed'));
 
-    // Display the entity.
-    $entity = field_test_entity_test_load($id);
-    $entity->content = field_attach_view($entity_type, $entity);
-    $this->content = drupal_render($entity->content);
-    $this->assertRaw($value, t('Value is displayed unfiltered'));
+      // Edit and change the text format to the new one that was created.
+      $edit = array(
+        "{$this->field_name}[$langcode][0][format]" => $format_id,
+      );
+      $this->drupalPost(NULL, $edit, t('Save'));
+      $this->assertRaw(t('test_entity @id has been updated.', array('@id' => $id)), t('Entity was updated'));
+
+      // Display the entity.
+      $entity = field_test_entity_test_load($id);
+      $entity->content = field_attach_view($entity_type, $entity);
+      $this->content = drupal_render($entity->content);
+      $this->assertRaw($value, t('Value is displayed unfiltered'));
+    }
   }
 }
 
 class TextSummaryTestCase extends DrupalWebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Text summary',
       'description' => 'Test text_summary() with different strings and lengths.',
       'group' => 'Field types',
Index: modules/field_ui/field_ui.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/field_ui/field_ui.api.php,v
retrieving revision 1.5
diff -u -9 -p -r1.5 field_ui.api.php
--- modules/field_ui/field_ui.api.php	26 Apr 2010 14:40:47 -0000	1.5
+++ modules/field_ui/field_ui.api.php	29 Apr 2010 21:42:42 -0000
@@ -52,39 +52,40 @@ function hook_field_settings_form($field
  *
  * @param $field
  *   The field structure being configured.
  * @param $instance
  *   The instance structure being configured.
  * @return
  *   The form definition for the field instance settings.
  */
 function hook_field_instance_settings_form($field, $instance) {
+  global $user;
+
   $settings = $instance['settings'];
 
-  $form['text_processing'] = array(
-    '#type' => 'radios',
-    '#title' => t('Text processing'),
-    '#default_value' => $settings['text_processing'],
-    '#options' => array(
-      t('Plain text'),
-      t('Filtered text (user selects text format)'),
-    ),
+  $formats = filter_formats($user);
+  $options = array('' => t('User selects text format'));
+  foreach ($formats as $format) {
+    $options[$format->format] = $format->name;
+  }
+  $form['format'] = array(
+    '#type' => 'select',
+    '#title' => t('Text format'),
+    '#options' => $options,
+    '#default_value' => $settings['format'],
+    '#attributes' => array('class' => array('filter-list')),
   );
   if ($field['type'] == 'text_with_summary') {
     $form['display_summary'] = array(
-      '#type' => 'select',
-      '#title' => t('Display summary'),
-      '#options' => array(
-        t('No'),
-        t('Yes'),
-      ),
-      '#description' => t('Display the summary to allow the user to input a summary value. Hide the summary to automatically fill it with a trimmed portion from the main post. '),
-      '#default_value' => !empty($settings['display_summary']) ? $settings['display_summary'] :  0,
+      '#type' => 'checkbox',
+      '#title' => t('Summary input'),
+      '#default_value' => $settings['display_summary'],
+      '#description' => t('This allows authors to input an explicit summary, to be displayed instead of the automatically trimmed text when using the "Summary or trimmed" display type.'),
     );
   }
 
   return $form;
 }
 
 /**
  * Widget settings form.
  *
Index: modules/filter/filter.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v
retrieving revision 1.328
diff -u -9 -p -r1.328 filter.module
--- modules/filter/filter.module	24 Apr 2010 14:53:59 -0000	1.328
+++ modules/filter/filter.module	29 Apr 2010 21:42:42 -0000
@@ -754,18 +754,20 @@ function check_markup($text, $format_id 
  *
  * @see filter_form_after_build()
  *
  * @param $element
  *   The form element to process. Properties used:
  *   - #base_type: The form element #type to use for the 'value' element.
  *     'textarea' by default.
  *   - #format: (optional) The text format id to preselect. If 0, NULL, or not
  *     set, the default format for the current user will be used.
+ *   - #formats: (optional) An array of possible format ids. If not set, all
+ *     formats accessible to the user are available.
  *
  * @return
  *   The expanded element.
  */
 function filter_process_format($element) {
   global $user;
 
   // Ensure that children appear as subkeys of this element.
   $element['#tree'] = TRUE;
@@ -815,29 +817,35 @@ function filter_process_format($element)
 
   // Prepare text format guidelines.
   $element['format']['guidelines'] = array(
     '#type' => 'container',
     '#attributes' => array('class' => array('filter-guidelines')),
     '#weight' => 20,
   );
   // Get a list of formats that the current user has access to.
   $formats = filter_formats($user);
+  if (isset($element['#formats'])) {
+    $formats = array_intersect_key($formats, array_flip($element['#formats']));
+  }
   foreach ($formats as $format) {
     $options[$format->format] = $format->name;
     $element['format']['guidelines'][$format->format] = array(
       '#theme' => 'filter_guidelines',
       '#format' => $format,
     );
   }
 
   // Use the default format for this user if none was selected.
   if (empty($element['#format'])) {
     $element['#format'] = filter_default_format($user);
+    if (isset($element['#formats']) && !in_array($element['#format'], $element['#formats'])) {
+      $element['#format'] = current($element['#formats']);
+    }
   }
   $element['format']['format'] = array(
     '#type' => 'select',
     '#title' => t('Text format'),
     '#options' => $options,
     '#default_value' => $element['#format'],
     '#access' => count($formats) > 1,
     '#weight' => 10,
     '#attributes' => array('class' => array('filter-list')),
