def _construct_form(self, i, **kwargs):
        """Set empty_permitted and instance for all forms."""
        kwargs["empty_permitted"] = False

        if self.is_bound:
            pk_key = "{0}-id".format(self.add_prefix(i))
            try:
                pk = int(self.data.get(pk_key))
            except (__HOLE__, TypeError):
                pk = None
            if pk:
                kwargs["instance"] = self._existing_object(pk)
            if kwargs.get("instance") is None:
                self.data[pk_key] = ""

        return super(BaseStepFormSet, self)._construct_form(i, **kwargs)
dataset/ETHPy150Open mozilla/moztrap/moztrap/view/manage/cases/forms.py/BaseStepFormSet._construct_form