

def make_organization_parameter_formset(org, extra=3):
    '\n    This is a workaround for passing custom parameters (the parameter owner in our case)\n    to a ModelFormset and is based on this stackoverflow answer:\n    http://stackoverflow.com/a/1376616\n    '

    class _OrganizationParameterCreateForm(forms.ModelForm):
        remove_from_list = forms.BooleanField(required=False)

        class Meta():
            model = OrganizationParameter
            fields = ['data_type', 'name', 'value', 'owner']
            widgets = {
                'data_type': forms.Select(attrs={
                    'class': 'form-control',
                }),
                'name': forms.TextInput(attrs={
                    'class': 'form-control',
                }),
                'value': forms.TextInput(attrs={
                    'class': 'form-control',
                }),
                'owner': forms.HiddenInput(),
            }

        def __init__(self, *args, **kwargs):
            super(_OrganizationParameterCreateForm, self).__init__(*args, **kwargs)
            self.fields['owner'].initial = org
    return modelformset_factory(OrganizationParameter, form=_OrganizationParameterCreateForm, extra=extra, can_delete=True)

dataset/ETHPy150Open 3bot/3bot/threebot/forms.py make_organization_parameter_formset/original