def formfield_for_dbfield(self, db_field, **kwargs):
    if (db_field.name == 'widget_type'):
        widgets = widget_manager.get_widgets(self.request.GET.get('page_id', ''))
        form_widget = WidgetTypeSelect(widgets)
        return forms.ChoiceField(choices=[(w.widget_type, w.description) for w in widgets], widget=form_widget, label=_('Widget Type'))
    if (('page_id' in self.request.GET) and (db_field.name == 'page_id')):
        kwargs['widget'] = forms.HiddenInput
    field = super(UserWidgetAdmin, self).formfield_for_dbfield(db_field, **kwargs)
    return field
def formfield_for_dbfield(self, db_field, **kwargs):
    if (db_field.name == 'widget_type'):
        widgets = widget_manager.get_widgets(self.request.GET.get('page_id', ))
        form_widget = WidgetTypeSelect(widgets)
        return forms.ChoiceField(choices=[(w.widget_type, w.description) for w in widgets], widget=form_widget, label=_('Widget Type'))
    if (('page_id' in self.request.GET) and (db_field.name == 'page_id')):
        kwargs['widget'] = forms.HiddenInput
    field = super(UserWidgetAdmin, self).formfield_for_dbfield(db_field, **kwargs)
    return field