I'm using FormBuilder 3.08 and I would like to have real labels on my form instead of just the column names. I'm thinking that it should be possible for me to put this label information into the Comments field for each column in the table. However....FormBuilder is just giving me labels with "1" in them. Here is my code. I'm on Windows XP SP3 using MySQL 5.2.44 and Active Perl 5.14.2. I've really tried to dig into this on the internet before asking..... Here is my code:
#------------------------------------------ # Get Label contents. #------------------------------------------ $sqlstatement=qq/SELECT column_name, column_comment FROM information_schema.columns WHERE table_name='preferences' AND table_schema = 'hypersort';/;
my $label_sth = $dbh->prepare($sqlstatement); $label_sth->execute() || die "Could not execute SQL statement ... maybe invalid?";
fields can take either; labels requires a hashref.
> I've been programming for a long time, but am new to Perl and CGI, and
> am still confused about the various fetchrow variations.
I'm not very familiar with the fetch* methods either. I usually skip the
prepare() and execute() steps and use one of the selectall_* methods
instead to return the complete query.
> On Monday, October 22, 2012 11:33:16 AM UTC-6, Norton Allen wrote:
> On 10/22/2012 12:42 PM, Harry Jamieson wrote:
>> #------------------------------------------ >> # Init new form.
>> #------------------------------------------ >> my $form = CGI::FormBuilder->new(
>> title => 'HyperSort Default Settings',
>> fields => \@pref_fields,
>> values => $defs,
>> labels => \@label_contents,
>> action => '/scripts/conn2.pl <http://conn2.pl>',
>> submit => [qw/Cancel Update/],
>> stylesheet => '/scripts/conn2.css',
>> );
> Harry, According to the documentation
> <http://formbuilder.org/download/CGI-FormBuilder-3.08/docs/CGI/FormBui...>,
> the 'labels' option takes a hashref, not an arrayref, presumably
> pairing the field name with the desired label.
Opps. My bad! Trying to finish the post before lunch. :( I guess that I will just have to play with this some more. Playing is the best way to learn...
> fields can take either; labels requires a hashref.
> I've been programming for a long time, but am new to Perl and CGI, and > am still confused about the various fetchrow variations.
> I'm not very familiar with the fetch* methods either. I usually skip the > prepare() and execute() steps and use one of the selectall_* methods > instead to return the complete query.
> Harry
> On Monday, October 22, 2012 11:33:16 AM UTC-6, Norton Allen wrote:
I've solved this problem, though probably not with the elegance that someone with more Perl knowledge would have. I simply read it in as an array, and this gave me my column_comment information without the spurious column heading from the schema.
$sql_stmt=qq/SELECT column_comment FROM information_schema.columns WHERE table_schema = 'hypersort' AND table_name='preferences';/;
$label_sth = $dbh->prepare($sql_stmt); $label_sth->execute() || die "Could not execute SQL statement ... maybe invalid?";
On Monday, October 22, 2012 1:04:22 PM UTC-6, Harry Jamieson wrote:
> Opps. My bad! Trying to finish the post before lunch. :( I guess that > I will just have to play with this some more. Playing is the best way to > learn...
> Harry
> On Monday, October 22, 2012 12:08:38 PM UTC-6, Norton Allen wrote:
>> On 10/22/2012 2:00 PM, Harry Jamieson wrote:
>> Hmmmm, down in the quickrefs it says that it can take either...
>> # Create form >> my $form = CGI::FormBuilder->new(
>> fields can take either; labels requires a hashref.
>> I've been programming for a long time, but am new to Perl and CGI, and >> am still confused about the various fetchrow variations.
>> I'm not very familiar with the fetch* methods either. I usually skip the >> prepare() and execute() steps and use one of the selectall_* methods >> instead to return the complete query.
>> Harry
>> On Monday, October 22, 2012 11:33:16 AM UTC-6, Norton Allen wrote: