1

I'm guessing it's not possible, since what works on other instances won't for the title & body. (Trying to adjust widget weight.)

  $core_instances = array(
    // array(
    //   'field_name' => 'title',
    //   'entity_type' => 'node',
    //   'bundle' => 'article',
    //   'weight' => 1,
    // ),
    // array(
    //   'field_name' => 'body',
    //   'entity_type' => 'node',
    //   'bundle' => 'article',
    //   'weight' => 4,
    // ),
    array(
      'field_name' => 'field_tags',
      'entity_type' => 'node',
      'bundle' => 'article',
      'weight' => 7,
    ),
    array(
      'field_name' => 'field_image',
      'entity_type' => 'node',
      'bundle' => 'article',
      'weight' => 6,
    ),
  );

  foreach ($core_instances as $instance) {
  $instance_info = field_info_instance($instance['entity_type'], $instance['field_name'], $instance['bundle']);
  $instance_info['widget']['weight'] = $instance['weight'];
  field_update_instance($instance_info);
  }

If I uncomment the title & body instances, I get the following error:

FieldException: Attempt to update an instance of a nonexistent field . in [error] field_update_instance()

4

The Title is not a field unless you're using the Title module. That's why your first call doesn't work.

Body should work, unless you've deleted the field (can you see it on admin/structure/types/manage/article/fields?)

  • Thanks, you're right about body, I assumed it was something about them both. For my purposes, being able to adjust body is enough, since I can weight the fields around it. – Merrick Sep 20 '13 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.