You are here

function slickgrid_plugin_modal_form_process in Slickgrid 7

Same name and namespace in other branches
  1. 7.2 plugins/editors/ModalForm.inc \slickgrid_plugin_modal_form_process()

Retrieve form / process a modal form This uses ctools ajax & the whole form so it works with all fields

Parameters

object $editor:

1 string reference to 'slickgrid_plugin_modal_form_process'
ModalForm.inc in plugins/editors/ModalForm.inc
Provides an inline cell editor

File

plugins/editors/ModalForm.inc, line 31
Provides an inline cell editor

Code

function slickgrid_plugin_modal_form_process($editor) {

  // Include the ctools stuff
  ctools_include('modal');
  ctools_include('ajax');
  $form_state['values'] = $_POST;

  // Additional form_state settings required for ctools modal forms
  $editor->entity_info = entity_get_info($editor->entity_type);
  $form_state['title'] = format_plural(count($editor->entities), 'Update 1 %type', 'Update @count %types', array(
    '%type' => strtolower($editor->entity_info['label']),
  ));
  $form_state['ajax'] = true;

  // Pass the editor object into the form_state
  $form_state['editor'] = $editor;
  $output = ctools_modal_form_wrapper('slickgrid_editor_form', $form_state);
  if (!empty($form_state['executed'])) {

    // Form has succesfully completed
    // We're going to exit the process, so get editor result manually
    $result = $form_state['editor']
      ->get_result();
    slickgrid_callback_get_messages($result);

    // Build a ctools ajax output array
    $output = array(
      array(
        'command' => 'slickgrid',
        'response' => array(
          'result' => $result,
        ),
      ),
    );
  }
  print ajax_render($output);
  exit;
}