Here's my simplified take on L's problem.  Maybe someone can offer some
advice.

Suppose one would like users to edit multiple records on one screen;
set a BooleanField for multiple records, say.  What would be the best
way to go about passing the form fields to the template?

One could create a custom manipulator containing a load of check boxes
tied to the different items or one could create an ChangeManipulator
for each record and pass a list of FormWrappers to the template.

For the simple tick box example custom manipulators would be the way to
go but adding in a couple more layers of complexity means that a load
of manipulators could be best.

The idea would be so that one could do something like this (error
fields needed IRL, obviously):

{% for form in list_of_forms_generated_from_list_of_manipulators %}

<label for="id_myFirstFormField">My First Form Field:</label> {{
form.myFirstFormField }}
...
<label for="id_myLastFormField">My Last Form Field:</label> {{
form.myLastFormField }}

{% endfor %}

request.POST['myFirstFormField'] et cetera would then contain a list of
the different values as entered by the user (a list of Trues and Falses
in the case of the checkboxes).

Can anyone offer any tips on what would be the best way to go about
things?  A list of ChangeManipulators seems the neatest solution but
I'm a little worried about the overhead of creating them and getting
form fields for each one.

Thoughts?

F.


PythonistL wrote:
> Let's suppose the following customs manipulator:
> ###########
> class OrderManipulator(formfields.Manipulator):
>       def __init__(self, basket_items=[]):
>               # First we store the IDs passed as we'll need them for the save
> method.
>               self.items = basket_items
>               # Now we need to         construct all of the fields which will 
> make up our
> form
>               new_fields = []
>               for item in basket_items:
>                       # We need to add all of the appropriate fields along 
> with the
> additional ID field
>                       # as detailed in the forum post
>                       new_fields.append(formfields.TextField(field_name="%s" 
> % item,
> maxlength=15))
>                       
> new_fields.append(formfields.TextField(field_name="%s_Name" % item,
> maxlength=100))
>                       
> new_fields.append(formfields.TextField(field_name="%s_Description" %
> item))
>                       
> new_fields.append(formfields.IntegerField(field_name="%s_Price" %
> item, maxlength=6))
>                       
> new_fields.append(formfields.IntegerField(field_name="%s_Vat" %
> item, maxlength=4))
>                       
> new_fields.append(formfields.IntegerField(field_name="%s_Pieces" %
> item, maxlength=6))
>                       
> new_fields.append(formfields.DatetimeField(field_name="%s_Date" %
> item))
>                       # The User field is ommited as we don't want it being 
> changed.
>               self.fields = new_fields
>               print self.fields
>
>       def save(self, new_data):
>               for item in self.items:
>                       temp = Order(
>                       Name=new_data["%s_Name" % item],
>                       Description=new_data["%s_Description" % item],
>                       Price=new_data["%s_Price" % item],
>                       Vat=new_data["%s_Vat" % item],
>                       Pieces=new_data["%s_Pieces" % item],
>                       Date=new_data["%s_Date" % item],
>                       orderkey=new_data["%s_orderkey" % item]
>                       )
>                       temp.save()
>               return temp
>
> #####################
>
>
> Is it possible to use that manipulator as ChangeManipulator?
> How populate a form with the correct (multiple values) data?
> The form should be a basket form when doing shoping and a user can
> change/delete items from his basket.
> 
> Thanks for help
> L.


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to