public function prepareForm(ModelInterface $model = null, array $data = null, $useInputFilter = false, $useHydrator = false)
    {
        $argv = compact('model', 'data');
        $argv = $this->prepareEventArguments($argv);
        $this->getEventManager()->trigger(self::EVENT_PRE_PREPARE_FORM, $this, $argv);
        $data = $argv['data'];

        /* @var $form Form */
        $form = $this->getForm(null, $this->formOptions);

        if ($useInputFilter) {
            $form->setInputFilter($this->getInputFilter());
        }

        if ($useHydrator) {
            $form->setHydrator($this->getHydrator());
        }

        if ($model) {
            $form->bind($model);
        }

        if ($data) {
            $form->setData($data);
        }

        $argv = compact('form', 'model', 'data');
        $argv = $this->prepareEventArguments($argv);

        $this->getEventManager()->trigger(self::EVENT_POST_PREPARE_FORM, $this, $argv);

        return $form;
    }