Gossamer Forum
Home : Products : DBMan SQL : Discussion :

admin unable to add record!

Quote Reply
admin unable to add record!
Hi,

I've set up a database where the primary key of the Company table = the userid. One company per user, so it seemed sensible...

As things stand, the admin user is unable to add Company records. The userid field is invisible on the add form, so when a record is added it is added with userid "admin". Is there any way I can make the userid field visible to admin, so admin can alter it?

I think you're going to tell me I have to do custom forms ....

thanks for any help
Tim Ault
Oxford UK
Quote Reply
Re: [timbo] admin unable to add record! In reply to
You won't be able to change the userid field, even it is visible on the add_form, unless you custom the add_record subroutine like:

.....
if ( $self->{cfg}->{'auth_user_field'} and !$self->{user}->{admin_p}) {
$self->{cgi}->{$self->{cfg}->{'auth_user_field'}} = $self->{user}->{'Username'};
}
....

To make userid field visible, just simply change 'HIDDEN' to 'TEXT' of 'Form Type' property.

TheStone.

B.
Quote Reply
Re: [TheStone] admin unable to add record! In reply to
I'd like to be sure I understand what this change does. Here's the code before your suggested change.

if ( $self->{cfg}->{'auth_user_field'} ) {
$self->{cgi}->{$self->{cfg}->{'auth_user_field'}} = $self->{user}->{'Username'};
}

Could you explain what the current code does, and what your change would do?

Also : I am having problems changing the comp_id from hidden to text. I get this error message "This table already has a primary key." which is true - this is the primary key. Any ideas?

I don't suppose there's any way I could get dbman sql to display automatically hidden primary key fields only when an admin user is adding a record ? This would save me a lot of time manually designing forms ...

many thanks
Tim Ault
Oxford UK

Last edited by:

timbo: Nov 18, 2003, 10:45 AM