skullvulture wrote: > Are form wrappers and manipulators only for creating 'change object' > and 'add object' forms? I'm creating a simple form that will have > several drop downs that correspond to fields in the database for one of > my objects, that will serve as a search form. Right now I have a basic > addManipulator so I can use the form wrapper to automatically generate > form fields, but that will only generate text fields rather than drop > downs of existing objects. Do I need to right my own form fields or is > there a way to get formwrappers and manipulators to do what I want?
Manipulators represent form controls in a form of any kind. FormWrapper is a little helper that just makes accessing controls from template more convenient. This means that you're perfectly able to do a manipulator for a search form. If you should use automatic AddManipulator as a base for your manipulator is another question. If it works similar enough this may be a good idea. But in your case it seams not because you still have to replace all of the automatically created fields with others that you need, and you need some custom 'search' method instead of automatic 'save' that you don't need at all. In this case it's better to create your own manipulator based on the abstract django.forms.Manipulator. It's utility would be mainly for doing validation and drawing a form with preset values when displaying errors. Here's a quick example (not tested) of such a manipulator: from django import forms class SearchManipulator(forms.SearchManipulator): def __init__(self): all_titles = # get all titles from db all_sizes = # get all sizes from db self.fields = [ forms.SelectField('title', is_required=True, choices=all_titles), forms.SelectField('size', choices=all_sizes), ] def search(self, data): result = MyModel.objects.filter(title=data['title']) if data['size']: result = result.filter(size=size) return result --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---