Re: Validation of dynamically generated forms

2007-10-11 Thread pinco
Frank, your snippet works great. I just removed the int conversion on bf_data, since I want to have f.is_valid() = false if the user submits something different than an integer. Without you I would never be able to solve the problem. Thanks a lot. On 11 Ott, 09:51, pinco <[EMAIL PROTECTED]> wr

Re: Validation of dynamically generated forms

2007-10-11 Thread pinco
Great! Thank you very much Frank. On 10 Ott, 22:03, FrankW <[EMAIL PROTECTED]> wrote: > I would swear that I posted a response to this earlier today, but it > doesn't seem to show up in the group. The problem you're having is > because of the 'cart_item_' that you are adding in. It is not being

Re: Validation of dynamically generated forms

2007-10-10 Thread FrankW
I would swear that I posted a response to this earlier today, but it doesn't seem to show up in the group. The problem you're having is because of the 'cart_item_' that you are adding in. It is not being added into the dictionary that is assigned to the form's data. >>> f.fields {'cart_item_a':

Re: Validation of dynamically generated forms

2007-10-10 Thread FrankW
If you look at f.errors or k.errors, you'll see: {'cart_item_b': [u'This field is required.'], 'cart_item_a': [u'This field is required.']} The reason for this is that the forms data looks like: {'a': '1', 'b': '2'} or {'a': 1, 'b': 2} The tricks that you're playing with changing the name of the

Re: Validation of dynamically generated forms

2007-10-08 Thread pinco
Frank, thak you for your help. I worked on the form model using bound field, and now the forms is bound. class CartForm(forms.Form): def __init__(self, a): super(CartForm, self).__init__(a) for key in a.keys(): self.fields['cart_ite

Re: Validation of dynamically generated forms

2007-10-06 Thread FrankW
In your example, self.fields[str(key)]=forms.CharField(initial=c[key]) isn't doing what you expect. You are setting the initial attribute of a field, not creating a BoundField. See django/newforms/forms.py, and look at the comments for BaseForm and Form and the code for BoundField. On Oct 6,

Validation of dynamically generated forms

2007-10-06 Thread pinco
Hi, I'm trying to figure out how to build a form to display x fields, where x is determined at runtime (e.g. a form to update the quantities of all the items in a shopping cart). My model is: class CartForm(forms.Form): def __init__(self, c, *args, **kwargs): super(Cart

Re: Validation of Dynamically generated forms.

2007-01-17 Thread mojo
ok, simple example: we need a form, that consists of questions. question is a django model and we can have any number of them. let's assume, that answer is a string, so we can use text widget (in my project type of field varied for questions). in manipulator's __init__ we iterate all questions t

Re: Validation of Dynamically generated forms.

2007-01-16 Thread [EMAIL PROTECTED]
oldforms since the newforms are still very much in development. --~--~-~--~~~---~--~~ 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 unsubscrib

RE: Validation of Dynamically generated forms.

2007-01-16 Thread mojo
: Validation of Dynamically generated forms. All of the examples in the Django documentation seem to deal only with hardcoded forms, in other words the programmer/designer knows how many field the form will/should have. I am creating a survey system. A survey will have X number of questions, so my

Validation of Dynamically generated forms.

2007-01-16 Thread [EMAIL PROTECTED]
All of the examples in the Django documentation seem to deal only with hardcoded forms, in other words the programmer/designer knows how many field the form will/should have. I am creating a survey system. A survey will have X number of questions, so my template is generic enough to handle X numb