Gossamer Forum
Home : Products : DBMan : Customization :

How can I auto-fill fields on just the add form?

Quote Reply
How can I auto-fill fields on just the add form?
By simply adding the value $db_userid on sub_html_record_form, I've gotten the user name to auto-fill in on all the forms. My problem is I want it only to auto-fill on the add form.

I'm guessing this is an if statement somewhere on sub_html_record_form, but I'm a complete neophyte when it comes to perl.

Thanks for any pointers.

Jason


Quote Reply
Re: [mrwumpus] How can I auto-fill fields on just the add form? In reply to
Use something like:
Code:
if ($in{'add_form'}) {
print qq|whatever you want to print when adding|;
}
else {
print qq|whatever prints when doing anything else|;
}

Place this where you want it (in html_record_form).

Also check out the 'unofficial faq' for more ideas on formatting, etc. http://webmagic.hypermart.net/dbman/



Quote Reply
Re: [Watts] How can I auto-fill fields on just the add form? In reply to
Excellent! That worked just fine. Thanks for your help.

Jason
Quote Reply
Re: [Watts] How can I auto-fill fields on just the add form? In reply to
Hi,

I know we can set userID auto fill in add form but how can we set whenever user login, it will auto fill in their userID and user name ? would you please show me.

Happy New YearCool
Quote Reply
Re: [britneythuyduong] How can I auto-fill fields on just the add form? In reply to
Are you referring to after they signup and then go to login?

If so, in sub html_signup_success you could change the fields to include the values such as:

<input type="text" name="userid" value="$in{'userid'}" ....

If they are just logging in on their own there is no way to know this information to have it automatically included.

You can have them use a URL which includes their username and password so that they can bypass the login screens.



Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] How can I auto-fill fields on just the add form? In reply to
Hi Lois,

If we know UserID 001 is A, userID 002 is B, userid 003 is C and userid 004 is D how can we make auto fill when userid 002 login it will have auto fill in Name B and UserID is 002 ? I just wonder can we do it ?

Thanks,Frown
Quote Reply
Re: [britneythuyduong] How can I auto-fill fields on just the add form? In reply to
I think there's no way to do this but store user and pwd information in cookies.

As for your original problem, I believe there's a better solution. html_record_form prints out each field value in the field when a value is passed to it:

my %rec = @_;# and then, a few lines later:

print qq|<input type="text" name="somefield" value="$rec{'somefield'} size="20">|;

On modification and delete forms, %rec will be passed to this code, so the values will exist. For add forms, no %rec will be passed - as there is nothing to be retrieved from the database when adding a record -, and that's why the field is empty. That means whatever you want to be filled in by default, you can assign to the $rec-value for that field. You don't have to fiddle with the print-statements, just do this:

if ($in{'add_form'}) { $rec{'somefield'} = "$db_userid";}

That way you don't have to change the print code of the form at all!

("somefield" = name of the field in the database)
kellner