Cannot access empty property on entity.inc line 277 when trying to access entity add page I created a new entity type with hook_entity_info using this code:

/**
 * Implements hook_entity_info().
 */
function custom_payment_entity_info() {
    return array(
        'custom_payment_period' =&gt; array(
            'label' =&gt; t('Period'),
            'plural label' =&gt; t('Periods'),
            'entity class' =&gt; 'Entity',
            'controller class' =&gt; 'EntityAPIController',
            'base table' =&gt; 'custom_payment_periods',
            'revision table' =&gt; 'custom_payment_period_revisions',
            'entity keys' =&gt; array(
                'id' =&gt; 'pid',
                'revision' =&gt; 'pvid',
            ),
            'fieldable' =&gt; TRUE,
            'static cache' =&gt; FALSE,
            'label callback' =&gt; 'entity_class_label',
            'uri callback' =&gt; 'entity_class_uri',
            'access callback' =&gt; 'custom_payment_access',
            'module' =&gt; 'custom_payment',
            'views controller class' =&gt; 'EntityDefaultViewsController',
            'admin ui' =&gt; array(
                'path' =&gt; 'admin/config/custom/custom-payment',
                'file' =&gt; '/forms/custom_payment.period.form.inc',
                'controller class' =&gt; 'EntityDefaultUIController',
                'menu wildcard' =&gt; '%period',
            ),
            'bundles' =&gt; array(
                'period' =&gt; array(
                    'label' =&gt; t('Period'),
                    'admin' =&gt; array(
                        'path' =&gt; 'admin/config/custom/custom-payment',
                        'access arguments' =&gt; array('administrator custom payment periods'),
                    )
                )
            )
        )
    );
}


But when i try to create new entity through the admin add page i get this error:


  Fatal error: Cannot access empty property in
  F:\xampp\htdocs\sfn\sites\all\modules\entity\includes\entity.inc on
  line 277


This is the form function:

function custom_payment_period_form($form, &amp;$form_state, $period = NULL) {
    $form['period'] = array(
        '#type' =&gt; 'textfield',
        '#title' =&gt; t('Period'),
        '#size' =&gt; 5,
        '#required' =&gt; TRUE,
        '#element_validate' =&gt; array('element_validate_integer_positive'),
        '#default_value' =&gt; isset($period-&gt;period) ? $period-&gt;period : ''
    );
    $form['type'] = array(
        '#type' =&gt; 'select',
        '#title' =&gt; t('Period Type'),
        '#options' =&gt; array(
            1 =&gt; t('Day'),
            2 =&gt; t('Month'),
            3 =&gt; t('Year')
        ),
        '#required' =&gt; TRUE,
        '#default_value' =&gt; isset($period-&gt;type) ? $period-&gt;type : ''
    );
    $form['price'] = array(
        '#type' =&gt; 'textfield',
        '#title' =&gt; t('Price'),
        '#size' =&gt; 5,
        '#field_suffix' =&gt; t('SYP'),
        '#required' =&gt; TRUE,
        '#element_validate' =&gt; array('element_validate_integer_positive'),
        '#default_value' =&gt; isset($period-&gt;price) ? $period-&gt;price : ''
    );
    $form['weight'] = array(
        '#type' =&gt; 'weight',
        '#title' =&gt; t('Position'),
        '#default_value' =&gt; isset($period-&gt;weight) ? $period-&gt;weight : ''
    );
    field_attach_form('period', $period, $form, $form_state);
    $form['actions'] = array(
        '#type' =&gt; 'actions',
        'submit' =&gt; array(
            '#type' =&gt; 'submit',
            '#value' =&gt; t('Save')
        )
    );
    return $form;
}


Can you help me fix this?



It's my first time working with entity type creation i followed the entity API documentation and the video entity example found here github.com/Lullabot/entity-api-demos/tree/master/docroot/sit‌​es/… i don't know exactly what is messing here.
Your entity keys don't seem to include bundle, label, or language. - @beth