You are here

InlineCell.inc in Slickgrid 7

Same filename and directory in other branches
  1. 7.2 plugins/editors/InlineCell.inc

Provides an inline cell editor

File

plugins/editors/InlineCell.inc
View source
<?php

/**
 * @file
 * Provides an inline cell editor
 */

// Plugin definition
$plugin = array(
  'title' => t('Inline cell'),
  'description' => t('A simple inline cell editor.'),
  'js' => array(
    'file' => 'slickgrid.editors.js',
  ),
  'css' => array(
    'file' => 'slickgrid.editors.css',
  ),
  'field_types' => array(
    'text_default',
    'number_integer',
  ),
  'process' => 'slickgrid_plugin_inline_cell_process',
  'error' => 'slickgrid_plugin_inline_cell_error',
  'handler' => array(
    'class' => 'slickgrid_editors',
  ),
);

/**
 * 
 * Process the inline cell update callback
 * @param object $editor
 */
function slickgrid_plugin_inline_cell_process($editor) {
  $_POST['op'] = t('Save');
  $entity = current($editor->entities);
  $langcode = field_language($editor->entity_type, $entity, $editor->field_id);
  $_POST[$editor->field_id][$langcode] = array(
    array(
      'value' => $_POST['value'],
    ),
  );
  $form_state['programmed'] = true;

  // Additional form_state settings required for ctools modal forms
  $editor->entity_info = entity_get_info($editor->entity_type);
  $form_state['values'] = $_POST;
  $form_state['editor'] = $editor;

  // Form isn't being displayed - so no rendering or redirecting
  $form_state['re_render'] = true;
  $form_state['no_redirect'] = true;

  // Build & submit the form
  drupal_build_form('slickgrid_editor_form', $form_state);
}

Functions

Namesort descending Description
slickgrid_plugin_inline_cell_process Process the inline cell update callback