Gossamer Forum
Home : Products : DBMan : Customization :

field type

Quote Reply
field type
i want to use columnar format for records. some fields are alpha, some are numer. i want to right align the numer and left align the others. i tried using the following:

if ($db_field_type{$col} eq "numer") {

and
if ($db_field_type{$field} eq "numer") {

but neither seemed to work. can someone tell me how to test the field type in the build_html_record section?

Quote Reply
Re: field type In reply to
From what you wrote I assume each field is either alpha or numeric (and not both), in which case you don't need to test the field type, you can simply do an align=left (or right) statement in the output table.

Quote Reply
Re: field type In reply to
guess i wasn't clear in my description. i have four fields in my database: three are numeric and one is alpha. i want to use the autogenerate instead of hardcoding the html. thus i need to test the field type in autogenerate routine so that it will align=right for the numeric fields and align=left for alpha field.

Quote Reply
Re: field type In reply to
If I were in your shoes I would assign a "-3" to numeric fields as a form-length and then add an extra formating section to the bulid_html_record_form in the cgi.

Something like :
elsif ($db_form_len{$field} == -3) {
$output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td align=right width=80%><input type=text name="$field" value="$rec{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>~;
}

Quote Reply
Re: field type In reply to
perhaps that would be easier if i can't figure out how to refer to the field type, but that does limit other options since i would no longer be able to specify a default length. you refered to $db_form_len{$field} and $db_lengths{$field}. do you know how to refer to the field type? is it $db_field_type{$field}?

Quote Reply
Re: field type In reply to
Try this.

In .cfg add variable at bottom
$db_field_types{$_} = $db_def{$_}[7];

In cgi add :
elsif ($db_field_types{$field} == "numer") {
$output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td align=right width=80%><input type=text name="$field" value="$rec{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>~;
}





Quote Reply
Re: field type In reply to
I can get the output to reformat but it is usually unconditional.

Why don't you turn auto forms off then you can format to your heart's content.




Quote Reply
Re: field type In reply to
thanks for pointing me in the right direction. as it turns out the field type was already defined as a variable in the cfg file -- it's $db_sort. using that, my conditional statement works great!