Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Adding Checkbox definition list

Quote Reply
Adding Checkbox definition list
I'm trying to add checkbox definitions the same way one adds radio buttons and select fields. I've followed the syntax exactly and consistently get the following error:
Not a SCALAR reference at Links/DBSQL.pm line 919.

This is my syntax:
%db_checkbox_fields = (
Performing_Arts => 'Yes,No'
);

I've successfully cut and pasted it into the %db_select_fields and %db_radio_fields and it works fine in both of those spots.

What am I doing wrong?
Quote Reply
Re: Adding Checkbox definition list In reply to
There's nothing specific on that in the forum, so if the syntax works in the other fields, then perhaps there is a problem with that routine.

You might want to email Alex if he doesn't respond here in the near future (probably swamped at the new year).

------------------
POSTCARDS.COM -- Everything Postcards on the Internet www.postcards.com
LinkSQL FAQ: www.postcards.com/FAQ/LinkSQL/








Quote Reply
Re: Adding Checkbox definition list In reply to
Try putting quotes around Performing_Arts as in 'Performing_Arts'. If that doesn't work, then it must be some other change?

Cheers,

Alex
Quote Reply
Re: Adding Checkbox definition list In reply to
Hi Alex,

That didn't work either. I'm still getting the same error message.

This is what my code looks like now
%db_checkbox_fields = (
'Performing_Arts' => 'Yes,No'
);

I've also checked mysql database settings to see if they are set to enum like the other fields. I've tried it as char, text, enum and none of them worked. mysql documentation suggests that a checkbox field should be a sset' instead of 'enum', but that only crashes the program, so that doesn't work either.

Is anyone else having problems with this? I didn't not make any changes to the original source code when I tried this, so if there is a problem, it's in the original source code that I received.

Looking forward to getting this one worked out.

Kyle
Quote Reply
Re: Adding Checkbox definition list In reply to
Sorry, must have had too much champange. That error is from HTML_Templates.pm. Look in %GLOBALS for get_date() and get_time() and remove the (). It should look like:

date => \&Links: BSQL::get_date,
time => \&Links: BSQL::get_time,

Cheers,

Alex
Quote Reply
Re: Adding Checkbox definition list In reply to
Alex, here's my code. Your suggestion to remove the () around data() and time() aren't the problem. They were never there, so that's not the problem either.
%GLOBALS = (
date => \&Links: BSQL::get_date,
time => \&Links: BSQL::get_time,
db_cgi_url => $LINKS{db_cgi_url},
build_root_url => $LINKS{build_root_url},
site_title => $LINKS{build_site_title},
css => $LINKS{build_css_url},
banner => ''
);
Quote Reply
Re: Adding Checkbox definition list In reply to
Hi Alex,

Thanks for the fix. Here's what you told me to change which solved the problem.

Try editing DBSQL.pm and change line 919 from:

my @boxes = split (/,/, ${$self->{'db_checkbox_fields'}});

to:

my @boxes = split (/,/, ${$self->{'db_checkbox_fields'}}{$column});

Quote Reply
Re: Adding Checkbox definition list In reply to
Okay, thanks Alex everything works fine now,

Now, for the rest of the changes

in db_utils.pm
sub cgi_to_hash{

change:
foreach ($in->param) { $rec{$_} = join "\0", $in->param($_); }

to:
foreach ($in->param) { $rec{$_} = join ",", $in->param($_); }

in DBSQL.pm sub build_checkbox_field {
my @boxes = split (/,/, ${$self->{'db_checkbox_fields'}}{$column});

Where it says split /,/ the , must reflect the delimiter in sub_cgi_to_hash. The delimiter WILL BE PRINTED when you build, so you can choose your
own, but it has to be the same in both places..

Finally, in admin.cgi

sub modify_record_mult {

change:
# Create the list of hashes.
foreach $key ($in->param) {
$key =~ /^(.+?)\-(\d+)$/ and ($links{$2}{$1} = $in->param($key));
}

to:
# Create the list of hashes.
my %in = %{&cgi_to_hash($in)};
foreach $key (keys %in) {
$key =~ /^(.+?)\-(\d+)$/ and ($links{$2}{$1} = $in{$key});
}


That should take care of it all.

Peace.

Kyle

[This message has been edited by klangan (edited February 07, 2000).]