I want to create my own version of the add/edit form for an entity defined in contrib module (drupal_commerce). I assumed i'd be able to adapt the example here http://www.foreach.be/blog/how-manipulate-forms-drupal-8 to alter route for entity forms. However i am getting the following when i try to load edit
Fatal error: Call to a member function getEntityTypeId() on a non-object in C:\xampp\htdocs\tocyn\core\lib\Drupal\Core\Entity\EntityForm.php on line 82
My route subscriber looks like:
if ($route = $collection->get('entity.commerce_product.edit_form') ) {
$defs = $route->getDefaults();
$route->setDefault('_form', '\Drupal\mymod\Form\EventForm');
}
And my new form:
class EventForm extends Drupal\commerce_product\Form\ProductForm
{
public function buildForm(array $form, FormStateInterface $form_state)
{
// doing nothing much here
return $form;
}
}
Do i need to do something with _entity_form also?? Grateful for any feedback Mathew