Fatal error: Call to a member function extractFormValues() : Drupal 8 beta 14 I created a module with Drupal 8 beta11 which defines an content entity and a form (contentEntityForm) with custom submit callback.When I tried using the same module with Drupal 8 beta 14 it raise the following error.


  Fatal error: Call to a member function extractFormValues() on null in C:\xampp\htdocs\drupalbeta14\core\lib\Drupal\Core\Entity\ContentEntityForm.php on line 219


Form definition are like this:

public function buildForm(array $form, FormStateInterface $form_state) {

        $form['employee']['first_name'] = array(
            '#type' =&gt; 'textfield',
            '#title' =&gt; 'First Name',
        '#required' =&gt; true,

        );
     $form['employee']['last_name'] = array(
            '#type' =&gt; 'textfield',
            '#title' =&gt; 'Last Name',
        '#required' =&gt; true,

        );
  $form['submit'] = array(
        '#type' =&gt; 'submit',
        '#value' =&gt; 'Submit',
        '#name' =&gt; 'employee-data',
        '#submit' =&gt; array('::submitEmployeeData')

    );
return $form
}
// callback

public function submitEmployeeData(array $form, FormStateInterface $form_state){
     /some code here
}


After form submission it raises the error mentioned above.

I checked the contentEntityForm.php also on both beta11 and beta 14 and seems to have similar function definition for extractFormValues() function.
This question is old but I stumbled across this issue as well, so posting the solution for future googlers..

Basically, you need to init the form_state within the buildForm method with:

if (!$form_state-&gt;has('entity_form_initialized')) {
  $this-&gt;init($form_state);
}


I found this solution here: https://withpulp.com/blog/drupal-forms-api/#initialize-the-form-state

When extending the ContentEntityForm class the parent buildForm normally handles this for you, but if for some reason you choose not to extend the buildForm you will need to init the form_state yourself.