You are here

function _editablefields_drupal_get_form in Editable Fields 5

Same name and namespace in other branches
  1. 5.3 editablefields.module \_editablefields_drupal_get_form()
  2. 5.2 editablefields.module \_editablefields_drupal_get_form()
2 calls to _editablefields_drupal_get_form()
editablefields_views_pre_query in ./editablefields.module
_editablefields_entry_form in ./editablefields.module

File

./editablefields.module, line 376

Code

function _editablefields_drupal_get_form($process = false, $type, $view) {
  $form_id = $type . '_node_form';
  $node = array(
    'uid' => $user->uid,
    'name' => $user->name,
    'type' => $type,
    'language' => '',
  );
  $form_state = array(
    'storage' => NULL,
    'submitted' => FALSE,
  );
  $form_state['post'] = $_POST;
  $form = drupal_retrieve_form($form_id, $node);
  $form_build_id = 'form-' . md5(mt_rand());
  $form['#build_id'] = $form_build_id;
  $form['editablefields_addnew_form'] = array(
    '#type' => 'hidden',
    '#value' => $type,
  );
  foreach ($view->argument as $id => $arg) {
    if (preg_match('/^content: (field_.*)$/', $arg['type'], $matches)) {
      $fieldname = $matches[1];
      $form['editablefieldsfiltervalue_' . $fieldname] = array(
        '#type' => 'value',
        '#value' => array(
          $view->args[$id],
        ),
      );
    }
  }
  foreach ($view->filter as $filter) {
    if (preg_match('/^node_data_(.*)\\.\\1_(.*)$/', $filter['field'], $matches)) {
      $fieldname = $matches[1];
      $valuename = $matches[2];
      $form['editablefieldsfiltervalue_' . $fieldname] = array(
        '#type' => 'value',
        '#value' => $filter['value'],
      );
    }
  }
  drupal_prepare_form($form_id, $form, $form_state);
  if (!empty($form['#cache'])) {

    // By not sending the form state, we avoid storing the storage which
    // won't have been touched yet.
    form_set_cache($form_build_id, $form, NULL);
  }
  unset($form_state['post']);
  $form['#post'] = $_POST;
  if ($process) {
    drupal_process_form($form_id, $form, $form_state);
  }
  return $form;
}