You are here

function menu_link_field_presave in Menu Link (Field) 7

Implements hook_field_presave().

See also

menu_link_menu_link_update()

File

./menu_link.field.inc, line 170
Defines a menu link field type.

Code

function menu_link_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
  foreach ($items as $delta => &$item) {
    if (empty($item['plid'])) {
      $item['plid'] = 0;
    }
    $item += array(
      'options' => array(),
      'hidden' => 0,
      'expanded' => 0,
      'weight' => 0,
    );

    // Add a key to indicate we are saving menu links from within a field. This
    // key is not stored in the database and will only be available during the
    // current request.
    // @see menu_link_menu_link_update()
    $item['menu_link_field_save'] = $field['field_name'];

    // TODO This could override the module column!
    $item['module'] = 'menu_link';
  }
}