You are here

function jeditable_field_formatter_view in jEditable inline content editing 7

@todo: field collection delta needs to be fixed --< field_delta line 153 Implements hook_field_formatter_view().

File

./jeditable.module, line 139
jeditable.module TODO: Provides integration between Drupal and the jEditable jquery plugin @todo: Datepicker support @todo: Ajax upload support @todo: Radioboxes/checkboxes support @todo: add required handler for date @todo: add compatibility for…

Code

function jeditable_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, &$items, $display) {
  $path = drupal_get_path('module', 'jeditable');
  $elements = array();
  if (empty($items)) {
    $items[0]['value'] = variable_get('jeditable_empty_placeholder', t('- None -'));
  }
  list($tmp, $widget_type) = explode('_', $display['type']);
  switch ($display['type']) {
    case 'jeditable_textfield':
    case 'jeditable_textarea':
    case 'jeditable_select':
    case 'jeditable_upload':
    case 'jeditable_datetime':
    case 'jeditable_checkbox_radio':
      foreach ($items as $delta => $item) {
        $field_delta = isset($display['views_field']) ? $display['views_field']->options['delta_offset'] + $delta : $delta;
        $elements[$delta] = array(
          '#markup' => theme('jeditable_formatter_' . $display['type'], array(
            'element' => $item,
            'field' => $instance,
            'entity' => $entity,
            'entity_type' => $entity_type,
            'widget_type' => $widget_type,
            'delta' => $field_delta,
          )),
        );
      }
      break;
  }
  foreach ($items as $delta => $item) {
    if (user_access('use jeditable')) {
      $elements[$delta]['#attached'] = array(
        'js' => array(
          $path . '/drupal_jeditable.js',
          $path . '/jquery.jeditable.mini.js',
        ),
        'css' => array(
          $path . '/jeditable.css',
        ),
      );
    }
  }
  return $elements;
}