ile has asked for the wisdom of the Perl Monks concerning the following question:

i have the following problem with CGI::Formbuilder:
i want to create a form which should be the interface to a database,
meaning it should insert the data. this form should have partly dynamic fields, meaning for example

i have a field called "friends" every user adding content, has a different amount of friends.
how to do this within one form?
i have to do it in one form, as the entries should be _not_ inserted
into the db when the user does not finish the form...
i thought about creating a button which says "add friend" - when this
button (or image) is clicked, it sends the whole form data again to the
same form, plus some additional variable (let's call it friends_amount),
counting up (which indicates how much friends-insert fields it should have).

from the point of formbuilder, the friends-fields should be rendered in
a loop, depending on the friends_amount variable. the naming of the form
fields must be "variable variables" - as i don't know about any better
solution until now...

my questions:
* is this possible?
* any hints, comments?
* any better ways to do this? (i.e. with multi-page-forms?)

thanx :)
ile

Replies are listed 'Best First'.
Re: dynamical forms with CGI::FormBuilder?
by parasew (Beadle) on Sep 26, 2003 at 17:33 UTC
    most of the stuff you want to archive by having a user-defined amount of fields for some reason, i would try with the Multiple Selects of  CGI::FormBuilder.
    another way would be to have two seperate forms...

    but i think the best way is the one suggested by the formbuilder creators.

    your idea with pushing data into the array should also work, but i am not so sure about how to handle that...