I have node creation form in a popup dialog box. I decided to give it a try using ctools modal window. But I seem to be getting errors when I upload an image into a image field after using browse to select it.
Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'node_form' was given in drupal_retrieve_form() (line 795 of /var/www/html/test/includes/form.inc).
Notice: Undefined index: #node in comment_form_node_form_alter() (line 1193 of /var/www/html/test/modules/comment/comment.module).
Notice: Trying to get property of non-object in comment_form_node_form_alter() (line 1210 of /var/www/html/test/modules/comment/comment.module).
Notice: Undefined index: #node in menu_form_node_form_alter() (line 629 of /var/www/html/test/modules/menu/menu.module).
Notice: Trying to get property of non-object in menu_form_node_form_alter() (line 629 of /var/www/html/test/modules/menu/menu.module).
Notice: Undefined index: #node in menu_form_node_form_alter() (line 630 of /var/www/html/test/modules/menu/menu.module).
Notice: Trying to get property of non-object in menu_form_node_form_alter() (line 630 of /var/www/html/test/modules/menu/menu.module).
Notice: Undefined index: field_artwork_image in file_ajax_upload() (line 271 of /var/www/html/test/modules/file/file.module).
Notice: Undefined index: #suffix in file_ajax_upload() (line 280 of /var/www/html/test/modules/file/file.module)
Below is my code
function portfolio_cust_node_add_modal_callback($js = FALSE) {
global $user;
//If people are not using JS. I just tell them "sorry" it is '2012'
if (!$js) return "Javascript required";
ctools_include('node.pages', 'node', '');
ctools_include('modal');
ctools_include('ajax');
// Create a blank node object here.
$node = (object) array(
'uid' => $user->uid,
'name' => (isset($user->name) ? $user->name : ''),
'type' => 'psuedo_portfolio',
'language' => LANGUAGE_NONE,
);
$form_state = array(
'title' => t('Add Portfolio'),
'ajax' => TRUE,
);
$form_state['build_info']['args'] = array($node);
drupal_add_library('system', 'ui.dialog');
// change this to your type node form
$output = ctools_modal_form_wrapper('psuedo_portfolio_node_form', $form_state);
// This means the form has been exectued
if (!empty($form_state['executed'])) {
$output = array();
// Close the modal
$output[] = ctools_modal_command_dismiss();
}
print ajax_render($output);
exit;
}
I am planning to use colorbox module or some other method which uses a iframe instead of how ctools implements the modal dialog.
Any help will be greatly appreciated.