Function linkit_form_field_ui_field_edit_form_alter() does not check whether a field is locked or not. Line 125

$allowed_widget = in_array($form['instance']['widget']['type']['#value'], $allowed_widget_types);

generates the following error notice:

Notice: Undefined index: instance in linkit_form_field_ui_field_edit_form_alter() (line 125 of sites\all\modules\linkit\linkit.field.inc).

It might be wise to check if the field is not locked and if the instance is defined:

if (!empty($form['locked']) || empty($form['instance'])) {
  return;
}

Thanks for all!

Comments

anon’s picture

How do I lock a field?

lmeurs’s picture

Linkit does not have to lock any fields, other modules apparently do to disallow users to change field settings. Linkit is not aware of a field's locked property, tries to approach the field and causes a warning.

The Field API docs state (https://api.drupal.org/api/drupal/modules%21field%21field.module/group/field/7):

locked (integer): Whether or not the field is available for editing. If TRUE, users can't change field settings or create new instances of the field in the UI. Defaults to FALSE.

I had to search a bit to find where I encountered the error message: it happened while developing a Drupal Commerce website at admin/commerce/config/order/fields when altering the Line item (commerce_line_items) and Order total (commerce_order_total) fields. These field are defined by Drupal Commerce and do not allow editing. Drupal does not show a configuration form, but outputs instead:

The field Order total is locked and cannot be edited.

anon’s picture

Ok thanks, I will take a look at this.

anon’s picture

Version: 7.x-2.x-dev » 7.x-3.x-dev
Issue summary: View changes
Status: Active » Fixed

This is now fixed for 7.x-3.x.

I'll not fix this for 7.x-2.x now, as that branch soon will be abandoned.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.