0

I have a scenario where I would like to reload/re-render the ctools_custom_content_type_edit_form after closing another ctools modal. To do so, I've bound an ajax object to the .close element within the open modal that will fire an ajax callback to open the ctools_custom_content_type_edit_form again.

My ajax callback looks like this, where the parent form is an argument in the menu callback. In this particular scenario, that form id is ctools_custom_content_type_edit_form.

The form is rendered, but it seems to be missing fields: Administrative Title, Title, Body. Any help would be appreciated. Let me know if you need more information.

function mymodule_parent_modal_callback($js, $parent_form_id) {
  // Convert parent form id
  $parent_form_id = str_replace ('-', '_', $parent_form_id);
  $path = '' . drupal_get_path('module', 'wysifield');

  if ($js) {
    ctools_include('modal');
    ctools_include('ajax');
  }
  else {
    // Someone navigated to the AJAX endpoint.
    drupal_access_denied();
  }

  $form_state = array(
    'ajax' => TRUE,
    'title' => t('Parent Modal Form'),
  );

  $commands = ctools_modal_form_wrapper($parent_form_id, $form_state);

  // If form has been submitted, execute other ajax commands.
  if (!empty($form_state['executed'])) {
    // Add the responder javascript, required by ctools
    ctools_add_js('ajax-responder');

    // Create ajax command array, dismiss the modal window.
    $commands = array();
    $commands[] = ctools_modal_command_dismiss();
  }

  print ajax_render($commands);
  drupal_exit();

}
  • What fields are missing? – FriOne Jul 31 '14 at 5:16
  • I've updated my post. It's all of them really. – Jason Jul 31 '14 at 12:00
0

Look at if ($settings['custom_type'] == 'fixed') condition in ctools_custom_content_type_edit_form(). Problem in it I think. Also, look at ctools_custom_content_type_get_conf() and do all needed to this function return $settings['custom_type'] equal to 'fixed'. Maybe this will fix problem, change this value before ctools_modal_form_wrapper() like this: $form_state['subtype']['name'] = 'custom';

  • Hi, thanks for the direction. Adding the following did render the form correctly. Now, I just need to figure how to abstract this a bit so my callback can manage this form among others, which means I need to add another argument to my ajax callback to indicate which type of form I'm processing. $form_state['subtype'] = _ctools_default_content_type_content_type(); – Jason Jul 31 '14 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.