You are here

function draggableviews_handler_fieldapi::save in DraggableViews 7

Overrides draggableviews_handler::save

File

implementations/draggableviews_handler_fieldapi.inc, line 17
The default implementation for draggableviews.

Class

draggableviews_handler_fieldapi

Code

function save($nid, $value) {
  $node = node_load($nid);
  $field_name = $this->field->field;

  // Get field.
  if (!isset($node->{$field_name})) {

    // This note doesn't this field.
    return;
  }
  $field =& $node->{$field_name};
  if (!isset($value)) {

    // Sometimes there is no value available (e.g. a root node without a parent).
    $value = 0;
  }
  $field_type = $this->field->options['type'];
  $language = $node->language;

  // Differ between certain field types.
  switch ($field_type) {
    case 'node_reference_plain':
      $field[$language][0]['nid'] = $value;
      break;
    default:
    case 'number_integer':
      $field[$language][0]['value'] = $value;
      break;
  }
  node_save($node);
}