On Tue, Sep 12, 2006 at 02:35:54PM -0500, Adrian Holovaty wrote:
> Let's change this to be similar to model classes, like so:
> 
> class ContactForm(Form):
>     sendername = TextField()
>     senderemail = EmailField()
>     subject = TextField(maxlength=20, blank=True)
>     message = TextField()
> 

I've got two thoughts that I'd like to see.

Inter-field dependency. For example:

class AdminTicketForm(Form):
    ...
    state = SelectField()
    solution = TextField(blank=True)
    related_to = SelectField(blank=True)
    field = TextField(blank=True)
    depends_on_field = TextField(blank=True)

Now in this case I actually want to say that is state equals 'resolved'
then solution needs to be filled and if state equals 'duplicate' then
related_to needs to be filled. That's an actual case I have in my app.
The field 'field' is just there as an example of the general case: if
field is not blank then neither should depends_on_field. Putting this in
the class seems natural, so maybe something like:

    state = SelectField()
    solution = TextField(blankunless='state == resolved')
    related_to = SelectField(blankunless='state == duplicate')
    field = TextField(blank=True)
    depends_on_field = TextField(blankunless='field')

Is this something that is worthwhile? It would be really useful for me,
and I bet other people would like it too. The syntax isn't quite right I
think, but that can always be improved.

The other thing has to do with hidden fields in Forms. Typically if
people want to have a field passed through, but not editable, you set it
as hidden. Of course hidden values can be edited by the enterprising
user. Basically maintaining the 'follow' attribute of
ChangeManipulators, and making sure that I can put values back in easily
to the BoundForm (or whatever it's called). Not too worried about this
going away, but just want to make sure.

Otherwise I really like the proposal so far, and I'll chime in and give
a +1 to having just Form and not Form and BoundForm.

Thanks

-- 
Scott Paul Robertson
http://spr.mahonri5.net
GnuPG FingerPrint: 09ab 64b5 edc0 903e 93ce edb9 3bcc f8fb dc5d 7601

Attachment: pgpmSzKO0tQ34.pgp
Description: PGP signature

Reply via email to