Gossamer Forum
Home : Products : DBMan : Customization :

question about add_form

Quote Reply
question about add_form
i would like to call the add_form subroutine with a hyperlink:
<a href=http://www.mydomain.com/db.cgi?db=default&uid=default&add_form=1>
which works fine.
What i need is to give some data for the database in this hyperlink, lets say something like:
a href=http://www.mydomain.com/db.cgi?db=default&uid=default&add_form=1&name=myname&adress=mystreet>
the values for name and adress should be in the add_form
is this possible?
thank you in advance

Bernd

Quote Reply
Re: question about add_form In reply to
You have to pass those parameters somehow. And you have to create an account first to add a record. So, first of all, you cannot use the default userid. So, to be short, the link you are wanting to use will not work.

Regards,

Eliot Lee

Quote Reply
Re: question about add_form In reply to
After the user logs in, is that possible? The link will like this: http://server/cgi-bin/db.cgi?db=dbname&uid=$uid&add_form=1&category=something.

This is also what I want to do. The purpose is to pass some defualt value to the add_form such as to let user to choose a category which is a select field in my db, there are too many selections, so it's better to let user to choose his option in a static page before going to the add_form, and whatever he selected will be passed to the form and be displayed somewhere in the add_form.

Long

Quote Reply
Re: question about add_form In reply to
Yes...after they login and if you have data stored in the .pass that can be passed to the .db file, then yes, you can use the link you provided.

Wink

Regards,

Eliot Lee

Quote Reply
Re: question about add_form In reply to
Thanks, Eliot

Then how can I display the value the user chosen in the add_form. For example, the user has selected a category, like subcategory1, then in the add_form, I would like to display "Category:subcategory1" somewhere in the form. Can I do it in this way: print "Category:$rec{'Category'}"? (Category is a select field name of my db)

Long

Quote Reply
Re: question about add_form In reply to
In sub html_record_form, after

my (%rec) = @_;

add

Code:
if ($in{'add_form'}) {
$rec{'category'} = $in{'category'};
}
JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: question about add_form In reply to
Hi, JPDeni

Your codes work great! Thank you very much!

Long

Quote Reply
Re: question about add_form In reply to
Thank you.
in my db, also an default user user can add records.
what i need is a way to create links-on-the-fly for dbman outside of dbman.
so it would be possible to add a whole record with add_record=1&id=1&name=myname etc etc
but i want the user to be able to fill some fields, so there has to add_form before add_record, but already with some parameters.
i guess i can figure out it from inside dbman, but here i´m really stuck (perl???)
than you
bernd

Quote Reply
Re: question about add_form In reply to
You can do the same thing I told "Long."

Your link can be

add_form=1&id=1&name=myname etc etc

Except that it would be better not to put the "id" in the link. Let DBMan do that. (It will do it automatically when you go to the add form.)

Then, at the beginning of sub html_record_form, use

Code:
if ($in{'add_form'}) {
$rec{'FieldName1'} = $in{'FieldName1'};
$rec{'FieldName2'} = $in{'FieldName2'};
$rec{'FieldName3'} = $in{'FieldName3'};
}
Use however many field names you need.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: question about add_form In reply to
Thank you a lot. I´ll try to figure it out!
best wishes
Bernd