1

I want to open create content type in modal, according to modal form and modal api example, I implement it, I test

the problem is here when I test it by contact form

    ctools_include('modal');
  ctools_include('ajax');
  $form_state = array(
    // 'title' => t('Contact'),
    'ajax' => TRUE,
  );
  module_load_include('inc', 'contact', 'contact.pages');
  $output = ctools_modal_form_wrapper('contact_site_form', $form_state);

every thing work correctly and there is no problem,but when I change it to

ctools_include('modal');
  ctools_include('ajax');
  $form_state = array(
    // 'title' => t('Contact'),
    'ajax' => TRUE,
  );
module_load_include('inc', 'node', 'node.pages');
$output = ctools_modal_form_wrapper('page_node_form', $form_state);

return me ** An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /drupal-7.24/share/ajax/1 StatusText: Service unavailable (with message) ResponseText: EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7724 of /includes/common.inc).** , where is the problem?

I create a menu, and it open a modal,I want add content in that modal

1 Answer 1

5

EntityMalformedException: Missing bundle property on entity of type node

This means that at some point in code when the node entity should be handled, it is unclear what type (bundle) that is. Now when you look at node_form() you see that it expects a node object as a parameter. If that's not given the node add form doesn't know what fields and properties to render because the node type can't be identified. Looking further into node_add(), which is the function normally called to create a new node of a specific type, I think you could go along the following lines (completely untested):

global $user;
ctools_include('modal');
ctools_include('ajax');
$node = (object) array(
  'uid' => $user->uid,
  'name' => (isset($user->name) ? $user->name : ''),
  'type' => 'page',
  'language' => LANGUAGE_NONE,
);
$form_state = array(
  'ajax' => TRUE,
  'build_info' => array(
    'args' => array($node),
  ),
);
module_load_include('inc', 'node', 'node.pages');
$output = ctools_modal_form_wrapper('page_node_form', $form_state);
4
  • tnx, great answer, but the submit not work, the node not saved (save button not perform anything) !!! why?
    – Yuseferi
    Commented Jan 24, 2014 at 9:33
  • 1
    @zhilevan: Take a look at this example: gist.github.com/mrconnerton/1979037
    – berliner
    Commented Jan 24, 2014 at 9:36
  • Great, ;) thank you very much.really helpful and reserved my time :)
    – Yuseferi
    Commented Jan 24, 2014 at 9:44
  • 1
    Glad to help, that was a quicky :)
    – berliner
    Commented Jan 24, 2014 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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