In some cases there are fields that have no instances. Then the field_ui fails to show them under "Add existing field" and it's not possible to create instances for these fields using the UI.

Steps to reproduce

  1. Create a field without an instance. For example using this code
    $field = [
      'field_name' => 'field_no_instance, 
      'type' => 'text', 
    ];
    field_create_field($field);
    
  2. Navigate to "manage fields" on any code content type.

Expected result

The field shows up in "Add existing field".

Actual result

The field doesn't show up in "Add existing field".

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

torotil created an issue. See original summary.

torotil’s picture

This patch changes field_ui_existing_field_options() to first loop over all existing fields (field_read_fields()) and then optionally add a better label and default widget by looping over existing field instances

Status: Needs review » Needs work

The last submitted patch, 2: 2869266-2-field_ui-show-fields-without-instances.patch, failed testing.

torotil’s picture

This time without the new array syntax.