0

I've built a ctools modal form with multi step like this, and I've built a ctools modal node form like this.

Cool! but now I want a ctools multi-step modal node form. Yes, I could render all the fields via Form API, hang all the validation & custom widgets and then write my own submit handler, but why bother when the node form would do that for me already?

Any help would be greatly appreciated.

mzy
  • 1,754
  • 2
  • 20
  • 36
dotist
  • 63
  • 8

1 Answers1

0

I figured it out. The trick was to load the node into the $form_state as an argument, then there are a couple ways you can render the form (see below).

ctools_include('node.pages', 'node', '');
$form_state['build_info']['args'] = array($node);
$output = ctools_modal_form_wrapper('my_content_type_node_form', $form_state);
print ajax_render($output);

ctools_include('node.pages', 'node', '');
$form_state['build_info']['args'] = array($node);
$form = drupal_retrieve_form('my_content_type_node_form', &$form_state);
print ajax_render($output);

My reason for wanting this was to avoid having to re-include all the submission handlers & validation that the node form already possesses. However due to the ajax, if you have a file upload in your form, you'll also need this:

form_load_include($form_state, 'inc', 'node', 'node.pages');
dotist
  • 63
  • 8