> Not sure about trunk but in newforms-admin at least you can just
> subclass your model field and overwrite formfield() to get the admin
> to use another form field. That way you can declare a custom form
> field (or just a standard one like RegexField) to tweak your
> validation for the forms generated from your model by ModelForm or
> form_from_instance()/form_from_model().

Yes, I've had success now with formfield_for_dbfield and returning a
custom field.  A clean_<field> function on the form also works by
overriding the default form returned from form_change (or form_add) in
the ModelAdmin class:

class ModelAdminOptions(ModelAdmin):
    [....]
    def form_change(self, request, obj):
        form = super(ModelAdminOptions, self).form_change(request,
obj)
        def clean_field(form):
            from django.newforms.util import ValidationError
            raise ValidationError('error test')
        form.clean_field = clean_field
        return form

So far so good - but I make extensive use of inline models, of which
the exposed hooks in InlineModelAdmin are formset_change and
formset_add - neither of which appear to have hooks for clean
functions.  Since Field instances don't have access to the parent form
data, I therefore can't say "if field A is not None, field B is
required".  Any idea how to accomplish the same ideas via inline
formsets via the admin in newforms-admin?

I've been going in circles with this; any help would be appreciated.

Thanks
Dan


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to