You are here

function theme_views_editablefields_handle_field in Editable Fields 5

Same name and namespace in other branches
  1. 5.3 editablefields.module \theme_views_editablefields_handle_field()
  2. 5.2 editablefields.module \theme_views_editablefields_handle_field()

Themeable function to handle displaying a specific field.

File

./editablefields.module, line 215

Code

function theme_views_editablefields_handle_field($fields, $field, $data) {
  $info = $fields[$field['fullname']];
  if ($field['options'] == 'editable') {
    $node = node_load($data->nid);
    if (node_access("update", $node)) {
      if ($info['content_field']['field_name']) {
        $form = array();
        global $viewfield_stack;
        $tmp = $viewfield_stack;
        $viewfield_stack = array();
        $form = _editablefields_content_form_field($node, $info['content_field']['field_name']);
        $viewfield_stack = $tmp;
        foreach (element_children($form) as $key) {
          $form["editablefield_" . $data->nid . "_" . $key] = $form[$key];
          unset($form[$key]);
        }
        $form = _editablefields_make_form_ids_unique($form, $data->nid);
        $form = form_builder('editableviewfield', $form);
        return $form = drupal_render_form('editableviewfield', $form);
      }

      // no access, so silently just print field out.
    }
    else {
      drupal_set_message("enable CCK if you wish to edit fields");
    }
  }
  if ($field['handler'] && function_exists($field['handler'])) {
    return $field['handler']($info, $field, $data->{$field}['queryname'], $data);
  }
  if ($info['handler'] && is_string($info['handler']) && function_exists($info['handler'])) {
    return $info['handler']($info, $field, $data->{$field}['queryname'], $data);
  }
  return check_plain($data->{$field}['queryname']);
}