Home : Products : DBMan : Customization :

Products: DBMan: Customization: Re: [acravens] Custom field "label" mod: Edit Log

Here is the list of edits for this post
Re: [acravens] Custom field "label" mod
Can't guarantee this will work but give it a try - you'll need to do some hacking and change things in more than one place (especially in db.cgi) - save a back up copy before tweaking the script.

Change this (in default.cfg):

Code:
# Database Definition
# --------------------------------------------------------
# Definition of your database. Format is
# field_name => ['position', 'field_type', 'form-length', 'maxlength', 'not_null', 'default', 'valid_expr']

%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Title => [1, 'alpha', 40, 255, 1, '', ''],
URL => [2, 'alpha', 40, 255, 1, 'http://', '^http://'],
Type => [3, 'alpha', 0, 60, 1, '', ''],
Date => [4, 'date', 12, 15, 1, &get_date, ''],
Category => [5, 'alpha', 0, 255, 1, '', ''],
Description => [6, 'alpha', '40x3', 500, 0, '', ''],
Validated => [7, 'alpha', 0, 3, 1, 'Yes', 'Yes|No'],
Popular => [8, 'alpha', 0, 3, 0, '', ''],
Userid => [9, 'alpha', -2, 15, 0, '', '']
);



to this:
Code:
# Database Definition
# --------------------------------------------------------
# Definition of your database. Format is
# field_name => ['position', 'field_type', 'form-length', 'maxlength', 'not_null', 'default', 'valid_expr', 'description']

%db_def = (
ID => [0, 'numer', 5, 8, 1, '', '', 'this is the ID'],
Title => [1, 'alpha', 40, 255, 1, '', '', 'this is the title'],
URL => [2, 'alpha', 40, 255, 1, 'http://', '^http://', 'this is the URL'],
Type => [3, 'alpha', 0, 60, 1, '', '', 'this is the type'],
Date => [4, 'date', 12, 15, 1, &get_date, '', 'this is the Date'],
Category => [5, 'alpha', 0, 255, 1, '', '', 'this is the category'],
Description => [6, 'alpha', '40x3', 500, 0, '', '', 'this is the description'],
Validated => [7, 'alpha', 0, 3, 1, 'Yes', 'Yes|No', 'this is validated'],
Popular => [8, 'alpha', 0, 3, 0, '', '', 'this is popular or not'],
Userid => [9, 'alpha', -2, 15, 0, '', '', 'this is the username - it may not always show']
);


2. Change this:
Code:
# ===========================================================================
# Build up some variables from your definitions. Internal use only.
foreach (sort { $db_def{$a}[0] <=> $db_def{$b}[0] } keys %db_def) {
push (@db_cols, $_);
$db_sort{$_} = $db_def{$_}[1];
$db_form_len{$_} = $db_def{$_}[2];
$db_lengths{$_} = $db_def{$_}[3];
$db_not_null{$_} = $db_def{$_}[4];
$db_defaults{$_} = $db_def{$_}[5];
$db_valid_types{$_} = $db_def{$_}[6];
($_ eq $db_key) and $db_key_pos = $db_def{$_}[0];
}

to this:

Code:
# ===========================================================================
# Build up some variables from your definitions. Internal use only.
foreach (sort { $db_def{$a}[0] <=> $db_def{$b}[0] } keys %db_def) {
push (@db_cols, $_);
$db_sort{$_} = $db_def{$_}[1];
$db_form_len{$_} = $db_def{$_}[2];
$db_lengths{$_} = $db_def{$_}[3];
$db_not_null{$_} = $db_def{$_}[4];
$db_defaults{$_} = $db_def{$_}[5];
$db_valid_types{$_} = $db_def{$_}[6];
$db_description{$_} = $db_def{$_}[7];
($_ eq $db_key) and $db_key_pos = $db_def{$_}[0];
}


Then modify this sub in db.cgi by sticking $db_description{$field} wherever you want the description to display (see bolded part for example)


sub build_html_record_form {
# --------------------------------------------------------
# Builds a record form based on the config information.
#
my (%rec) = @_;
my ($output, $field);

$output = "<p><table border=0>";
foreach $field (@db_cols) {
if ($db_select_fields{$field}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_select_field($field, $rec{$field}) . "</td></tr>"; }
elsif ($db_radio_fields{$field}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_radio_field($field, $rec{$field}) . "</td></tr>"; }
elsif ($db_checkbox_fields{$field}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_checkbox_field ($field, $rec{$field}) . "</td></tr>"; }
elsif ($db_form_len{$field} =~ /(\d+)x(\d+)/) {
$output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><textarea name="$field" cols="$1" rows="$2">$rec{$field}</textarea></td></tr>~; }
elsif ($db_form_len{$field} == -1) { $output = qq~<input type=hidden name="$field" value="$rec{$field}">$output~; }
elsif ($db_form_len{$field} == -2) { $per_admin ? ($output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><input type=text name="$field" value="$rec{$field}" maxlength="$db_lengths{$field}"></td></tr>~) :
($output = qq~<input type=hidden name="$field" value="$rec{$field}">$output~); }
else { $output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%> $db_description{$field} <input type=text name="$field" value="$rec{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>~; }
}
$output .= "</table></p>\n";
return $output;
}

Last edited by:

Watts: Jan 14, 2005, 4:20 PM

Edit Log: