public function getForm($documentClass = null)
    {
        if (null === $documentClass) {
            $documentClass = $this->getDocumentClass();
        }

        $builder = new AnnotationBuilder();
        $form = $builder->createForm($documentClass);

        $hasDocument = false;
        foreach ($form->getElements() as $element) {
            if (method_exists($element, 'setObjectManager')) {
                $element->setObjectManager($this->getDocumentManager());
                $hasDocument = true;
            } elseif (method_exists($element, 'getProxy')) {
                $proxy = $element->getProxy();
                if (method_exists($proxy, 'setObjectManager')) {
                    $proxy->setObjectManager($this->getDocumentManager());
                    $hasDocument = true;
                }
            }
        }

        if ($hasDocument) {
            $hydrator = new DoctrineObjectHydrator($this->getDocumentManager(), $documentClass);
            $form->setHydrator($hydrator);
        } else {
            $form->setHydrator(new ClassMethods());
        }

        $form->add([
            'type' => 'Zend\Form\Element\Csrf',
            'name' => 'csrf',
            'attributes' => [
                'id' => 'csrf',
            ],
        ]);

        $submitElement = new \Zend\Form\Element\Button('submit');
        $submitElement->setAttributes([
            'type' => 'submit',
            'class' => 'btn btn-primary',
        ]);
        $submitElement->setLabel('Salvar');
        $form->add($submitElement, [
            'priority' => -100,
        ]);

        $cancelarElement = new \Zend\Form\Element\Button('cancelar');
        $cancelarElement->setAttributes([
            'type' => 'button',
            'class' => 'btn btn-default',
            'onclick' => 'top.location=\''.$this->url()
                ->fromRoute($this->getActionRoute('list')).'\'',
        ]);
        $cancelarElement->setLabel('Cancelar');
        $form->add($cancelarElement, [
            'priority' => -100,
        ]);

        return $form;
    }