You are here

function cmis_block_settings_more_items_js in CMIS API 6

1 string reference to 'cmis_block_settings_more_items_js'
cmis_content_menu in cmis_content/cmis_content.module
Implementation of hook_menu() for CMIS module.

File

cmis_content/cmis_content.module, line 318

Code

function cmis_block_settings_more_items_js() {
  $delta = count($_POST['cmis_target_document_items']);

  // Build our new form element.
  $form_element = _cmis_content_block_settings_path_form($delta);
  drupal_alter('form', $form_element, array(), 'cmis_block_settings_more_items_js');

  // Build the new form.
  $form_state = array(
    'submitted' => FALSE,
  );
  $form_build_id = $_POST['form_build_id'];

  // Add the new element to the stored form. Without adding the element to the
  // form, Drupal is not aware of this new elements existence and will not
  // process it. We retreive the cached form, add the element, and resave.
  if (!($form = form_get_cache($form_build_id, $form_state))) {
    exit;
  }
  $form['block_settings']['cmis_target_document_items'][] = $form_element;
  form_set_cache($form_build_id, $form, $form_state);
  $form += array(
    '#post' => $_POST,
    '#programmed' => FALSE,
  );

  // Rebuild the form.
  $form = form_builder('block-admin-configure', $form, $form_state);

  // Render the new output.
  $items_form = $form['block_settings']['cmis_target_document_items'];
  unset($items_form['#prefix'], $items_form['#suffix']);

  // Prevent duplicate wrappers.

  //$choice_form[$delta]['#attributes']['class'] = empty($choice_form[$delta]['#attributes']['class']) ? 'ahah-new-content' : $choice_form[$delta]['#attributes']['class'] .' ahah-new-content';

  //$choice_form[$delta]['chvotes']['#value'] = 0;
  $output = theme('status_messages') . drupal_render($items_form);
  drupal_json(array(
    'status' => TRUE,
    'data' => $output,
  ));
}