Gossamer Forum
Home : Products : DBMan : Customization :

autofill field

(Page 2 of 2)
> >
Quote Reply
Re: autofill field In reply to
Hi again JPD,

I just tested using "" as opposed to "*" and it seems to work - so thanks, unless you have of some reason why my approach is not a good idea.

Thanks/Regards ais
Quote Reply
Re: autofill field In reply to
If it works, that's all that matters.


------------------
JPD





Quote Reply
Re: autofill field In reply to
For email addresses, use

<a href="mailto:$rec{'Email'}">$rec{'Email'}</a>

If your email field isn't named Email, change the variables above to match.

Quote:
When I enter a web site address (url), it is saved as a "clickable" link. However, when I edit the record, url is lost and I have to re-enter it.
My guess is that you have some sort of typo in your fieldname. I wouldn't know for sure unless I saw your html.pl file.




------------------
JPD





Quote Reply
Re: autofill field In reply to
Hi JPD,

You were right, I had a typo in the url's field name. I also have the email "clickable" now - thanks.

Still on forms though, I am getting the hang of it and making steady progress but I do have a couple of questions.

A couple of posts ago you gave me some examples of form field definitions code which I am using to develop my own form, and I refer in particular to the following

code:
--------------------------------------------------------------------------------

print qq| <table> <tr><td>Name:</td> <td><input type="text" name="Name" value="$rec{'Name'}"></td></tr><input type="hidden" name="Userid" value="$rec{'Userid'}"> <tr><td>Address:</td> <td><input type="text" name="Address" value="$rec{'Address'}"></td></tr>|;if ($per_admin) { print qq| <tr><td>Gender:</td> <td> |; print &build_radio_field("Gender","$rec{'Gender'}"); print qq|</td></tr>|;}else { print qq| <input type="hidden" name="Gender" value="$rec{'Gender'}">|;}print qq| <tr><td>Name of Pet:</td> <td><input type="text" name="Pet" value="$rec{'Pet'}"></td></tr> <tr><td>Favorite Color:</td> <td> |; print &build_select_field("Color","$rec{'Color'}"); print qq|</td></tr> </table> |;

--------------------------------------------------------------------------------


code:
--------------------------------------------------------------------------------

print qq| <table> <tr><td>Name:</td> <td>$rec{'Name'}</td></tr> <tr><td>Address:</td> <td>$rec{'Address'}</td></tr>|;if ($per_admin) { print qq| <tr><td>Gender:</td> <td>$rec{'Gender'}</td></tr>|;}print qq| <tr><td>Name of Pet:</td> <td>$rec{'Pet'}</td></tr>|;if ($rec{'Pet'}) { print qq| <tr><td>Favorite Color:</td> <td>$rec{'Color'}</td></tr>|;}print qq| </table> |;

--------------------------------------------------------------------------------

I am trying to understand it but have to admit I am a bit stumped by the Gender field and what it does.
Code:
if ($per_admin) { print qq| <tr><td>Gender:</td> <td> |; print &build_radio_field("Gender","$rec{'Gender'}"); print qq|</td></tr>|;}else { print qq| <input type="hidden" name="Gender" value="$rec{'Gender'}">|;}

I tried the code and for admin the field displays normally. Other than for admin, there is no field label in the left column nor any record content on the right - So I am wondering why use the else statement at all? - If I want to suppress the record content, why can't I just use the if ($per_admin) condition and leave out the rest - or was there some other intent with this example that I am missing? The only other thing I can think of is if the "if" statement followed the record label, then there would be a label but no record rather than a blank row - but even that does not need the else statement, which actually brings me to a question.

As admin I create all records and assign a userid. The "owner" of the record can only modify own. After I create the base record with all the required fields, the user (owner) can log on and fill in all other fields, however, when logging in, all the required fields (created by admin) can be seen but not edited (like a search result).

So basically something similar to your Gender example but for the else statement, instead of "hidden" it should be "visible but not editable" to coin my own Perl phrase. Please advise if this s possible.

My next question relates to hiding blank fields. If I am not mistaken, the Color field in your example, is an optional field which will not be visible unless a Pet name is entered. So if Pet is empty, Color is hidden. But what if I wanted to hide the Pet field itself assuming it was empty and not a required field.

I would appreciate your help please.

Thanks/regards ais
Quote Reply
Re: autofill field In reply to
 
Code:
print qq|
<tr><td>Gender:</td>
<td> |;
if ($per_admin) {
print &build_radio_field("Gender","$rec{'Gender'}"); print qq|</td></tr>|;
}
else {
print qq|
<input type="hidden" name="Gender" value="$rec{'Gender'}">$rec{'Gender'}</td></tr>|;
}

Code:
print qq|
<tr><td>Name of Pet:</td>
<td>$rec{'Pet'}</td></tr>|;
if ($rec{'Color'}) {
print qq|
<tr><td>Favorite Color:</td>
<td>$rec{'Color'}</td></tr>|;
}
print qq|
</table>
|;


------------------
JPD





Quote Reply
Re: autofill field In reply to
Hi again,

Just been experimenting with the form code and I think I may just have discovered the reason for your else statement in the Gender field. My understanding now is that if you do not print (even hidden print is ok) required fields in the record form when modifying, dbman cannot reference these fields and thinks they are blank even if they currently contain information (in the database file) and if they were not required fields, dbman would overwrite any stored data with blank entries.

This might save you an explanation for my first question - if I got it right, which would only leave my second question to be answered.



Regards ais

Quote Reply
Re: autofill field In reply to
Oops we crossed wires.

Your reply had not been posted when I started typing my last post.

I think I was on the right track with the else statement.

Thanks for the other codes. I will go back and work on my forms again.

I tell you autoforms must be the most time saving feature of dbman - if only they could be used everywhere.

Thanks/Regards ais
Quote Reply
Re: autofill field In reply to
I saw that we were doing some simulposting. Happens a lot.

Yes, autogenerated forms can be a time saver, but you sacrifice control over the look of the form and some other things. Also, the "clickable urls," "skip blank fields," and having the ability for radio, select, checkbox and textarea fields to be "admin-only" are new enhancements that I wrote.

Another way to start with a basic form that includes all of the autogenerated code would have been to use my "configurator" to build both sub html_record and sub html_record_form.


------------------
JPD





Quote Reply
Re: autofill field In reply to
Hi JPD

Thanks to your incredible help I have been able to get this script to do just about what I need.

I think my forms are almost perfect for my application except for one last feature I would like to customise.

Admin creates/deletes all records for users. Users can only modify own. Permission for modify_own=1.

At present, when creating the records, all records are automatically assigned the admin userid as admin is creating them. After creating them I can go back (as admin) and modify the record and assign it to the relevant user.

What I would like to do is, at the time of creating the record, I would like to manually type in the appropriate userid and have DBman create the record with the typed in userid as the owner and not as an admin owned record.

I would appreciate your help with some code for this please.

Thanks/Regards ais
Quote Reply
Re: autofill field In reply to
In db.cgi, sub add_record, change

Code:
# Set the userid to the logged in user.
($auth_user_field >= 0) and ($in{$db_cols[$auth_user_field]} = $db_userid);

to

Code:
# Set the userid to the logged in user.
unless ($per_admin) {
($auth_user_field >= 0) and ($in{$db_cols[$auth_user_field]} = $db_userid);
}

You could just delete the line, but it would take away some of the functionality of the script that you might want to use for other databases. This way, if the one who adds the record has admin permission, the field will not be filled in automatically. If the "adder" doesn't have admin permission, the field will be filled in.


------------------
JPD





Quote Reply
Re: autofill field In reply to
Hi JPD

Just a little thank-you note as a token of appreciation for your help.

Regards ais
> >