protected function isDisplayable(FormEvent $event, $i, $eventName)
    {
        $form = $event->getForm();
        $data = $event->getData();

        if (!isset($data[$i])) {
            return false;
        }

        $item = is_object($data[$i]) ? (array) $data[$i] : $data[$i];

        if (!is_array($item)) {
            return true;
        }

        if (FormEvents::PRE_SUBMIT === $eventName) {
            if (isset($item['__to_remove'])) {
                return !(bool) $item['__to_remove'];
            }
        }

        foreach ($item as $k => $v) {
            if (FormEvents::PRE_SUBMIT === $eventName &&
                HiddenType::class === get_class($form->get($i)->get($k)->getConfig()->getType()->getInnerType())
            ) {
                continue;
            }

            // Value not null
            if (null !== $v && '' !== $v) {
                return true;
            }
        }

        return false;
    }