You are here

function _draggableviews_get_form_element in DraggableViews 6

Same name and namespace in other branches
  1. 6.2 draggableviews.inc \_draggableviews_get_form_element()
1 call to _draggableviews_get_form_element()
template_preprocess_draggableviews_view_draggabletable in ./draggableviews_theme.inc
Display a view as a draggable table style.

File

./draggableviews.inc, line 333
Implements preprocess function hook_submit for draggable views

Code

function _draggableviews_get_form_element($nid, $field_name, $real_field_name, $value, $specific_field_name = NULL) {

  //watchdog('special', '<pre>'.print_r($view, true).'</pre>');

  // get content field

  //print_r($view->field[$field_name]);

  // get node type
  $node = node_load($nid);
  $type = content_types($node->type);
  $field = $type['fields'][$real_field_name];
  $field_types = _content_field_types();
  $field_type = $field_types[$field['type']];
  $widget_types = _content_widget_types();
  $widget_type = $widget_types[$field['widget']['type']];

  //$content_field = $view->field[$field_name]->content_field;

  // get cck widget type

  //$widget_type = !empty($content_field) ? $content_field['widget']['type'] : 'hidden';

  //watchdog('special', '<pre>'.print_r($view, true).'</pre>');
  switch ($field['widget']['type']) {
    case 'optionwidgets_select':
      return array(
        '#type' => 'select',
        '#name' => $specific_field_name != NULL ? $specific_field_name : $field_name . '_' . $nid,
        '#value' => $value,
        '#options' => content_allowed_values($field),
        '#attributes' => array(
          'class' => $field_name,
        ),
      );
      break;
    case '__nodereference_select':
      return array(
        '#type' => 'select',
        '#name' => $specific_field_name != NULL ? $specific_field_name : $field_name . '_' . $nid,
        '#value' => $value,
        '#options' => content_allowed_values($field),
        '#attributes' => array(
          'class' => $field_name,
        ),
      );
      return array(
        '#theme' => 'content_multiple_values',
        '#title' => 'parent',
        '#required' => 0,
        '#description' => NULL,
        0 => array(
          '#type' => 'nodereference_autocomplete',
          '#default_value' => array(
            'nid' => NULL,
            '_error_element' => 'default_value_widget][field_parent][0][nid][nid',
          ),
          '#value_callback' => 'nodereference_autocomplete_value',
          '#title' => 'parent',
          '#description' => NULL,
          '#required' => NULL,
          '#weight' => 0,
          '#delta' => 0,
          '#columns' => array(
            0 => 'nid',
          ),
          '#field_name' => 'field_parent',
          '#type_name' => 'task',
        ),
        '#field_name' => 'field_parent',
        '#tree' => 1,
        '#weight' => 3,
        '#access' => 1,
        '#count' => 5,
      );
    case 'hidden':
    default:
      return array(
        '#type' => 'hidden',
        '#name' => $field_name . '_' . $nid,
        '#value' => $value,
        '#attributes' => array(
          'class' => $field_name,
        ),
      );
  }
}