public function setForm(EntityForm $form)
    {
        if (!$form->isValid()) {
            throw new InvalidFormDataException(
                "Submitted form data is not valid."
            );
        }
        $this->setData($form->getData());
        $this->form = $form;
        return $this;
    }