0

i try to include a node creation form by a field attach form. So i try to load the entity of a custom content type created by the back-office with is called 'friterie'. But when i call the entity_create function i get this error : Call to undefined function entity_create()

Here is my code :

function fritr_register_friterie_form($form, &$form_state) {
    $form = array();

    // INCLUDE FRITERIE ADD FORM
    $form['friterie'] = array();
    //module_load_include('inc', 'node', 'node.pages'); this is an old method
    //$form['friterie'] = node_add('friterie');    
    global $language;
    $entity = entity_create('node', array('type' => 'friterie', 'language' => $language->language));
    //$form['friterie'] = field_attach_form('node', $entity, $form['friterie'], $form_state);

    // INCLUDE USER REGISTER FORM
    //$form['user'] = drupal_get_form('user_register_form');


    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Enregistrer la friterie'),
    );        

    dsm($form);
    return $form;
}

I don't know why i get this error, i watch on the official documentation and it says i can do it like i did :/

2
  • 2
    Can you verify if the Entity module is enabled? Do you have it installed? – Gulok Jun 20 '16 at 9:04
  • Ahm yep i've nit installed entity module... Sorry :s – Kpone Jun 20 '16 at 9:32
0

As Gulok said, check if the module entity is installed and enabled.

Be sure to add entity as a depencencie in your .info file as well.

0

As tenken said in related question

require_once "./includes/bootstrap.inc";
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

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.