I am trying to load a node edit form into a modal frame using Ctools. The following is the function I am using. So far the $op = 'view'
part is working fine, but I cannot get the node edit form to load when $op = 'edit'
. I have searched for the better part of the day, but I cant find anything about how to load node forms in a modal frame using Ctools in Drupal 7.
function namecards_modalframe_node($op, $nid, $js = FALSE) {
$output = '';
switch ($op) {
case 'view':
if ($js) {
ctools_include('ajax');
ctools_include('modal');
$output .= theme('namecards_download_cvs_link', $nid);
// Create table showing contact's information
$table_structure = namecards_get_table_data($nid);
$output .= theme('table', array('header' => $table_structure['header'], 'rows' => $table_structure['rows'], 'attributes' => $table_structure['attributes']));
$output .= theme('namecards_download_cvs_link', $nid);
// Add close button to bottom of page.
return ctools_modal_render(t('Details'), $output);;
}
else {
$output .= theme('namecards_download_cvs_link', $nid);
// Create table showing contact's information
$table_structure = namecards_get_table_data($nid);
$output .= theme('table', array('header' => $table_structure['header'], 'rows' => $table_structure['rows'], 'attributes' => $table_structure['attributes']));
$output .= theme('namecards_download_cvs_link', $nid);
// Add close button to bottom of page.
$form = drupal_get_form('namecards_modalframe_close_button_form');
$output .= drupal_render($form);
return $output;
}
break;
case 'edit':
// Include 'node.pages.inc' in order to be able to use node functions
module_load_include('inc', 'node', 'node.pages');
// form_load_include($form_state, 'inc', 'node', 'node.pages');
$node = node_load($nid);
if ($js) {
ctools_include('ajax');
ctools_include('modal');
$form_state = array(
'ajax' => $js,
'title' => t('Edit'),
'build_info' => array(
'args' => array(
'node' => $node,
),
),
);
return ctools_modal_form_wrapper('namecards_some_form', $form_state);
}
else {
$node_edit_form = node_page_edit($node);
return drupal_render($node_edit_form);
}
break;
}
}
Each time I click on the link, the modal frame opens but it is blank (accept for the loading animation). At the same time a js alert box appears containing the following:
An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /namecards/modalframe/node/edit/4585/ajax
StatusText: OK
ResponseText:
drupal7
@import url("http://drupal7/modules/system/system.base.css?lylwzg");
@import url("http://drupal7/modules/system/system.menus.css?lylwzg");
@import url("http://drupal7/modules/system/system.messages.css?lylwzg");
@import url("http://drupal7/modules/system/system.theme.css?lylwzg");
@import url("http://drupal7/misc/vertical-tabs.css?lylwzg");
@import url("http://drupal7/modules/contextual/contextual.css?lylwzg");
@import url("http://drupal7/modules/comment/comment.css?lylwzg");
@import url("http://drupal7/modules/field/theme/field.css?lylwzg");
@import url("http://drupal7/sites/all/modules/namecards/namecards.css?lylwzg");
@import url("http://drupal7/modules/node/node.css?lylwzg");
@import url("http://drupal7/modules/search/search.css?lylwzg");
@import url("http://drupal7/modules/user/user.css?lylwzg");
@import url("http://drupal7/sites/all/modules/views/css/views.css?lylwzg");
@import url("http://drupal7/sites/all/modules/ctools/css/ctools.css?lylwzg");
@import url("http://drupal7/modules/shortcut/shortcut.css?lylwzg");
@import url("http://drupal7/modules/toolbar/toolbar.css?lylwzg");
@import url("http://drupal7/themes/garland/style.css?lylwzg");
@import url("http://drupal7/themes/garland/print.css?lylwzg");
Skip to main content
Home
Hello drupal7
Log out
Administrative toolbarDashboard (View and customize your dashboard.)
Content (Administer content and comments.)
Structure (Administer blocks, content types, menus, etc.)
Appearance (Select and configure your themes.)
People (Manage user accounts, roles, and permissions.)
Modules (Extend site functionality.)
Configuration (Administer settings.)
Reports (View reports, updates, and errors.)
Advanced help
Help (Reference for usage, configuration, and modules.)
Hide shortcuts
Add content
Find content
Performance
Edit shortcuts
drupal7
Main menuBooks
Home
Namecards
Secondary menuMy account
Log out
Configure block
Search form
Search
Navigation
List links
Edit menu
Configure block
Add content
Development
List links
Edit menu
Configure block
Devel settings
Empty cache
Entity info
Execute PHP Code
Field info
Function reference
Hook_elements()
Menu item
PHPinfo()
Rebuild menus
Reinstall modules
Run cron
Session viewer
Theme registry
Variable editor
You are hereHome
Configure block
Powered by Drupal
Would appreciate any suggestions on how to get this working.