I'm trying to create a custom module and found out that it's causing the following error message to appear:
EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7721 of ~/includes/common.inc).
if (!isset($entity->{$info['entity keys']['bundle']}) || $entity->{$info['entity keys']['bundle']} === '') {
throw new EntityMalformedException(t('Missing bundle property on entity of type @entity_type.', array('@entity_type' => $entity_type)));
}
I'm using xdebug setup with netbeans to debug the error and found out what is causing the culprit.
I found out it was a specific field I added in my module that looks like this:
$form['base']['st-volume-pricing']['add'] = array(
'#type' => 'button',
'#value' => t('Add'),
'#name' => 'add_row',
'#limit_validation_errors' => array(
array('price'),
array('till-amount'),
),
'#ajax' => array(
'callback' => 'bulk_and_user_pricing_add_volume_standard_ajax_callback',
'wrapper' => 'error-placeholder',
'method' => 'append',
'effect' => 'fade',
),
'#prefix' => '<td>',
'#title' => t('Click this button to add a standard volume price'),
);
My debugger basically showed the following data:
$info['entity keys']['bundle'] = "type"
$entity_type = "node"
$entity stdClass
add string "Add"
add_row string "Add"
price string "123"
till-amount string "123"
I checked my database and couldn't find any nodes without type so that shouldn't cause any problems.
I suppose I have to define the bundle in my code somewhere but I'm not that famillair with bundles yet.
The field is added to the node edit page of a product created by the ubercart module using hook_form_FORM_ID_alter() -> hook_form_product_node_form_alter()
.
Does anyone have a clue as to what I should do to define the bundle?
Or in OOP terms, how can I make my field a class member of the ubercart product bundle (which is an extended class of the entity type base class)?