protected function getForm(FieldTypeInterface $field, $force = false)
    {
        $datasource = $field->getDataSource();

        if ($datasource === null) {
            return null;
        }

        if (!$field->getOption('form_filter')) {
            return null;
        }

        $field_oid = spl_object_hash($field);

        if (isset($this->forms[$field_oid]) && !$force) {
            return $this->forms[$field_oid];
        }

        $options = $field->getOption('form_options');
        $options = array_merge($options, ['required' => false, 'auto_initialize' => false]);

        $form = $this->formFactory->createNamed(
            $datasource->getName(),
            $this->isFqcnFormTypePossible()
                ? 'Symfony\Component\Form\Extension\Core\Type\CollectionType'
                : 'collection',
            null,
            ['csrf_protection' => false]
        );
        $fieldsForm = $this->formFactory->createNamed(
            DataSourceInterface::PARAMETER_FIELDS,
            $this->isFqcnFormTypePossible()
                ? 'Symfony\Component\Form\Extension\Core\Type\FormType'
                : 'form',
            null,
            ['auto_initialize' => false]
        );

        switch ($field->getComparison()) {
            case 'between':
                $this->buildBetweenComparisonForm($fieldsForm, $field, $options);
                break;

            case 'isNull':
                $this->buildIsNullComparisonForm($fieldsForm, $field, $options);
                break;

            default:

                switch ($field->getType()) {
                    case 'boolean':
                        $this->buildBooleanForm($fieldsForm, $field, $options);
                        break;

                    default:
                        $fieldsForm->add($field->getName(), $this->getFieldFormType($field), $options);
                }
        }

        $form->add($fieldsForm);
        $this->forms[$field_oid] = $form;

        return $this->forms[$field_oid];
    }