Gossamer Forum
Home : Products : DBMan SQL : Discussion :

I see hidden fields

Quote Reply
I see hidden fields
Hi,

The manual mentions on page 30 that hidden fields do not show when records are being viewed, added or modified. When I look at my search results (using the default templates), I do see the hidden fields. Unsure Am I doing something wrong, is this a bug in the manual or a bug in the software?

Jasper

http://www.bookings.org
Quote Reply
Re: [jaspercram] I see hidden fields In reply to
I'm having this problem too. Hidden fields don't appear on the add form, but do appear on the search results form. I don't want this. Am I doing something wrong?

thanks
Tim Ault
Oxford UK
Quote Reply
Re: [timbo] I see hidden fields In reply to
Hi guys, you have to modify the "add_form.html" (or any other template) on you r templates, so instead of filling it up automatically, you code in what fields to display, which are hidden, etc. Yea, first couple of days I had the program, you could do a user search and the search would even return the passwords... But ive gotten over that now, I code in everything now (adding the <field type=hidden name=secret value="this is top secret">)

I agree with what you guys posted that the manual was written by a programmer... which really becomes helpful once youve read it enough that you become a programmer... Perhaps they should go through this forum and add our "helps" to their manual... The forum is becoming too crowded to actually find something relevant to you.

Anyway, have fun!
Quote Reply
Re: [jaspercram] I see hidden fields In reply to
In Reply To:
... When I look at my search results (using the default templates) ... Am I doing something wrong ...?
Don't use the default templates!

If you write your own templates, specifying what you what to appear on the page, you won't have that problem.
Quote Reply
Re: [YoYoYoYo] I see hidden fields In reply to
This is crazy. If a field is defined as hidden, it should be hidden not only in the add_form page but also in the add_success and modify_success pages. What's the point of having a hidden field if it is then displayed to the user. GT - can we have a fix for this one please?
Tim Ault
Oxford UK
Quote Reply
Re: [YoYoYoYo] I see hidden fields In reply to
i have try to use my own templates but when trying to read and setup that table to use it does not work!?

what is the problem do you know?

can you send me an example of your customized add_form template so i can take a look what i am doing wrong if that is so!

my email is andre@circuitball.com send it to it

thanx
KevinW ANDRE
webmaster@cyberbrickell.com
Quote Reply
Re: [jaspercram] I see hidden fields In reply to
also same problem and the manual does not tell you how to fix it. anyway i have asked to the support stuff and still without a reply about it.

also when and add or modify is success i am getting the id numbers that show and not the real names of field i added or modify, can you tell me how to fix this? if you do...

thanx

also using the global

sub {
my $table = shift;
my $results = $DB->table($table)->select()->fetchall_hashref;
return { loop_select => $results };
}


i got this error when including in my form this

<%build_select('table_name')%>
<select name="select_name">
<%loop loop_select%>
<option value="<%column_id%>"><%column_description%></option>
<%endloop%>
</select>


this is the error in the form:

Error: Variable 'build_select' is not a code reference
KevinW ANDRE
webmaster@cyberbrickell.com
Quote Reply
Re: [kevinws] I see hidden fields In reply to
In Reply To:
i have try to use my own templates but when trying to read and setup that table to use it does not work!?

what is the problem do you know?

can you send me an example of your customized add_form template so i can take a look what i am doing wrong if that is so!

my email is andre@circuitball.com send it to it

thanx


Just copy the default add_form.html and replace the red code with ALL your fields -

<%include header.html%>
<form name="myform" action="db.cgi<%ifnot use_cookie%>?sid=<%session_id%><%endif%>" method="post" <%if enctype%><%enctype%><%endif%>>
<center>
<table border="<%if m > 0 and m < 25%>0<%else%>1<%endif%>" cellpadding="0" cellspacing="0">
<tr>
<td>
<%if sdo%><!--generate a form for related database-->
<%Dbsql::Relation::HTML::generate_add_form%>
<%else%>
<%if m > 0 and m < 25%> <!--Add multipe rows-->
<%Dbsql::HTML::generate_add_multi_form%>
<input name=m type=hidden value="<%m%>">
<%else%>
<%Dbsql::HTML::generate_add_form%>
<%endif%>
<%endif%>
</td>
</tr>
</table>
<p>
<table border=1 cellpadding=0 cellspacing=0>
<tr>
<td align=center>
<table border=0 width=500>
<tr>
<td align=center>
<center>
<font face='Tahoma,Arial,Helvetica' size='2' color='#000000'>
<%ifnot use_cookie%><input type=hidden name="sid" value=<%session_id%>><%endif%>
<input type=submit value="Add record" name="submit">
</font>
</center>
</td>
</tr>
</table>
</td>
</tr>
</table>
</center>
<p>
<input type="hidden" name="do" value="<%if m > 0 and m < 25%>add_multi_records<%else%>add_record<%endif%>">
<input type="hidden" name="db" value="<%db%>">


<%if sdb%>
<!--Subform-->
<input type=hidden name="sdb" value="<%sdb%>">
<input type=hidden name="sdo" value="<%if sdo%><%sdo%><%endif%>">
<input type=hidden name="sfk" value="<%if sfk%><%sfk%><%endif%>">
<%endif%>


<%if q%>
<!--Query objects-->
<input type=hidden name="q" value="<%q%>">
<%endif%>
</form>
<%include footer.html%>


Your fields should look something like the following -

Text Fields

<input type="text" name="field_name" size="20">

Select Fields

<select name="field_name">
<option value="some_value">some_name</option>
<option value="some_value">some_name</option>
</select>

Hidden Fields

<input type=hidden name="field_name" value="some_value">

etc....... (for other types of fields).

Hope this helps.

Simon.
Quote Reply
Re: [timbo] I see hidden fields In reply to
In Reply To:
This is crazy. If a field is defined as hidden, it should be hidden not only in the add_form page but also in the add_success and modify_success pages. What's the point of having a hidden field if it is then displayed to the user. GT - can we have a fix for this one please?


The templates supplied with DBManSQL are only examples and it's up to you to modify them. You can decide what fields to display but if you use the standard template it will always generate ALL fields to be displayed. A hidden field is alway hidden on the form but it depends on your code as to if it's shown on any result pages. You need to replace the red code in the following default add_success.html with the fields you want to display -

<%include header.html%>
<%ifnot m%>
<p>
<center>
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<td height="125">
<table bgcolor="#ffffff" border="0" cellpadding="3" cellspacing="3" width="500" valign="top">
<%Dbsql::HTML::generate_add_success%>
</table>
</td>
</tr>
</table>
<p>
</center>
<%endif%>
<p>
<%include footer.html%>


The code you add should look something like -

Title1: <%field_name%>

Title2: <%field_name%>

If you don't want the hidden field displayed, don't include it here.

Hope this helps.

Simon.
Quote Reply
Re: [jai] I see hidden fields In reply to
this is the global i need to use and is not working

i got this error: Error: Variable 'build_select' is not a code reference Frown

i sent this to gossamer support but thet did not sent me reply about

sub {
my $table = shift;
my $results = $DB->table($table)->select()->fetchall_hashref;
return { loop_select => $results };
}


i got this error when including in my form this

<%build_select('table_name')%>
<select name="select_name">
<%loop loop_select%>
<option value="<%column_id%>"><%column_description%></option>
<%endloop%>
</select>

i dont know what i am doing worng if so, you send me how to make a select field and works but i need to use this global because my fields in this tables are in relation with others that content the information and make the dropdown from those tables contents in this.

for examples i have the table that user will use for adding records modify etc... these contents

and every field are dropdown from another table content field. i cant get the global work! do you know can you give some sample with the phonec_id for example?

thanx Unimpressed

prate_id

phonec_id - taken from another table

contryf_id - taken from another table

contryt_id - taken from another table

cityt_id - taken from another table

value_id - taken from another table

phone_minutes
KevinW ANDRE
webmaster@cyberbrickell.com
Quote Reply
Re: [jai] I see hidden fields In reply to
Laughthank you for your great help JAI! would really worked for me!

REALLY APPRECIATE, I HAVE CHANGE ALL TEMPLATES BUT STILL STUCK IN THE SEARCH_RESULTS TEMPLATE BECAUSE I DONT KNOW HOW DO I DO TO REFERENCE THE FIELD LOCATED IN OTHERS TABLES

DO YOU KNOW?

EX:Unsure

I HAVE THE RELATIONAL TABLE T_PRATE

T_PRATE HAS THE FOLLOWING FIELDS

PRATE_ID | PHONEC_ID | COUNTRYF_IF | COUNTRYT_ID | PHONEC_CITY | VALUE_ID | PHONEC_MINUTES

THE PRATE_ID is the primary key for the table

phonec_id, countryf_id, countryt_id, value_id are fields that reference to others fields in others tables. i mean

phonec_id field belongs to the table t_phonec

countryf_id field belongs to the table t_countryf

countryt_id field belongs to the table t_countryt

value_id field belongs to the table t_value

now when listing all, searching or modifying a record i am getting from the (search results) form the numbers that belongs to the relational table field in the other table but not the real name.

Can you give me an example in how and what to change in the search_results so i got the real names for the listings searching, or modifying.

taking a look in the search_results i got Crazy

<%include header.html%>
<p>
<%if hits%>
<center>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<table bgcolor="#ffffff" border="0" width="500" valign="top">
<tr>
<td align=right>


<p align="center"><%speedbar%></p><p>
<%if sdo and $sdb%> <!--generate a form for related database-->
<%if hz%> <!-- horizontal display -->
<table border=1 cellpadding=0 cellspacing=0>
<tr><td>
<table border=0 width=500>
<tr bgcolor=#cccccc>
<%Dbsql::Relation::HTML::generate_header%>
</tr>
<%loop results%>
<tr>
<%Dbsql::Relation::HTML::generate_search_results%> </tr>
<%endloop%>
</table>
</td></tr>
</table>
<%else%>
<%loop results%>
<p>

<%Dbsql::Relation::HTML::generate_search_results%>
<%endloop%>
<%endif%>
<%else%>
<%loop results%>
<p><%Dbsql::HTML::generate_search_results%>
<%endloop%>
<%endif%>
<%if speedbar%><p align="center"><%speedbar%></p><%endif%>
</td>
</tr>
</table>
</td>
</tr>
</table>
</center>
<%endif%>
<p>
<%include footer.html%>


CAN YOU TELL ME AS BEFORE IN THE OTHER YOU HELPED ME A LOT WHAT TO CHANGE IN THIS TO GET WHAT I WANT?

THANX JAI,!

I AM LEARNING A LOT WITH YOU! Smile
KevinW ANDRE
webmaster@cyberbrickell.com
Quote Reply
Re: [kevinws] I see hidden fields In reply to
jai i tried to use this sintaxis but still showing in the search_results page the numbers of ids of the fields related to others tables and not the real name that correspond to that record id in that tables

see what i tried, i am getting the list with their ids but not the real names in the table field that belongs:

my questions what do i have to change in the sintaxis so the field <%countryf_id%>, <%countryt_id%>, ,<%value_id%> that belongs to other table can show me the relational name if this id and not the id....

do i have to use a global? what global? can you show me?Unsure

this is what i have now in search_results i put it anywhere to test it because i dont know where to place and what to delete from there to change it for this.. but anyway i can see that display the results but as i said only the ids.

see below:



<%loop results%>


<%phonec_id%><BR>
<%countryf_id%><BR>
<%countryt_id%><BR>
<%phonec_city%><BR>
<%value_id%><BR>
<%phonec_minutes%><BR><BR>


<%endloop%>
KevinW ANDRE
webmaster@cyberbrickell.com
Quote Reply
Re: [kevinws] I see hidden fields In reply to
I'm not really sure that I understand what you are doing but I think you need to modify your search_results. As you did with other templates, take out the code that generates the results -

<%Dbsql::Relation::HTML::generate_search_results%>

and replace it with exactly the fields you want to display.

If you want to display fields from another table based on the results you can try -

sub {
#Include all tags
my $tags = GT::Template->tags;
#Pull the field from the database
my ($some_name) = $DB->table(other_table_name)->select({field_name_in_other_table => $tags->{field_name_in_search_results} }, [name_of_the_field_you_want])->fetchrow_array();
#Assign the field to $tags
$tags->{name_of_the_field_you_want}=$some_name;
#Return. The field should be available in your template as <%name_of_the_field_you_want%>
return; }

I didn't test this but let me know if it does what you want. You can of course pull as many fields as you want from each table.

Simon.
Quote Reply
Re: [jai] I see hidden fields In reply to
Frowni don not know what i an doing wrogn but it is not working i just what to pull the data from others tables associated with the table in question that users have access in the results templates and i need to know what do i change here to pull those fields

right now i am using just as it says in the manual Smile

<%phonec_id%><BR>
<%countryf_id%><BR>
<%countryt_id%><BR>
<%phonec_city%><BR>
<%value_id%><BR>
<%phonec_minutes%><BR><BR>


and it works but show me the id associated in this table Crazybut not the field data from the table in relation with this.

can you suggest another way for the glogal you sent because it is not working maybe i am doing wrong i do not know but i guess so.Unsure
KevinW ANDRE
webmaster@cyberbrickell.com
Quote Reply
Re: [kevinws] I see hidden fields In reply to
In your first message you posted the following code -

sub {
my $table = shift;
my $results = $DB->table($table)->select()->fetchall_hashref;
return { loop_select => $results };
}


It should be -

sub {
my $table = 'table_name';
my $results = $DB->table($table)->select()->fetchall_hashref;
return { loop_select => $results };
}

See if that makes a difference.

If you use my code it should look something like -

sub {
#Include all tags
my $tags = GT::Template->tags;
#Pull the field from the database
my ($some_name) = $DB->table('t_phonec')->select({field_name_in_other_table => $tags->{field_name_in_search_results} }, ['phonec_id'])->fetchrow_array();
#Assign the field to $tags
$tags->{phonec_id}=$some_name;
#Return. The field should be available in your template as <%phonec_id%>
return; }

**You need to give it a field in both tables to search on, I don't know your table set up so I can't give you the field names.



One of the above should help.

Simon
Quote Reply
Re: [jai] I see hidden fields In reply to
this i need it for the results page not for the search the search i fit it already but it is that when after search to modify or delete or after search for a record take you to the results page template all time and this is the templates i got the problem.

i have these tables

t_countrf table

countryf_id | countryf_name

t_countryt table

countryt_id | countryt_name

t_value table

value_id | value_price

t_phonec table

phonec_id

phonec_name

t_prate table (this is the table that is accessed by the users only that relates to the others)

prate_id

phonec_id

countryf_id

countryt_id

value_id

phonec_minutes

right now i am using this as it says in the manual

<%phonec_id%><BR>
<%countryf_id%><BR>
<%countryt_id%><BR>
<%phonec_city%><BR>
<%value_id%><BR>
<%phonec_minutes%><BR><BR>


but does not work in the way to show the real names of the id field in these table from the relates tables. Right now show me the id numbers for countryf_id, countryt_id, phonec_id, value_id . I am triyng to pull the fields from the others tables but i can't get it worked i know the form i have to change is the search_results but i was trying the globals but does not make any change.

can you tell me why? something that has to be simple to pull is so Unsure to get it worked.

thanx

i have sent this quesiton to the IT of Gossamer and did not reply me about it yet you are more efficient that them i will try to send them my request again because the manual is so general and for programmers i have read it all and still not getting in there.
KevinW ANDRE
webmaster@cyberbrickell.com
Quote Reply
Re: [kevinws] I see hidden fields In reply to
I want to suppress the display of some fields in the long display for default user trying to list all records. For a list all like

........db.cgi?do=search_results&db=mydb&keyword=*&fm=long&uid=default

I have two databases, in one all fields that I do not want to display are hidden, and in the second case the fields fall in three categories -

1. Timestamp field
2. Hidden Fields
3. Some fields that are not hidden

To make this work, it is being suggested in this old (2003) post that the templates needs to customized. Whereas reading through the code specifically of
package GT::SQL::Display::HTML (which is given in file /admin/GT/SQL/Display/html.pm), I find that probably this package has all the code required to achieve that I want. Refer to the attributes setting at the top of this file (I have pasted that below).

$ATTRIBS = {
db => undef,
input => undef,
mode => '',
code => {},
font => $FONT,
hide_timestamp => 0,
hide_download => 0,
file_field => 0,
file_delete => 0,
file_use_path => 0,
view_key => 0,
defaults => 0,
search_opts => 0,
values => {},
multiple => 0,
table => 'border=0 width=500',
tr => '',
td => 'valign=top align=left',
extra_table => 1,
col_font => $FONT,
val_font => $FONT,
hide => [],
skip => [],
view => [],
disp_form => 1,
disp_html => 0,
url => $ENV{REQUEST_URI},
};


Reading through this and the code right at the end - I felt that by changing some the following

hide_timestamp => 0,
hide => [],
skip => [],
view => [],

I might be able to achieve it without modifying any template at all, only by changing these setting. Also there is a sub _skip(), which is used to skip hidden fields etc. Here is the sub from this package-

sub _skip {
# -------------------------------------------------------------------
my ($self, $col) = @_;
# Skip timestamps, any fields requested to be skipped or any hidden fields (hidden forms appended at bottom).
return 1 if ($self->{hide_timestamp} and $self->{cols}->{$col}->{time_check});
return 1 if ($self->{skip} and (grep /^$col$/, @{$self->{skip}}));
return 1 if ($self->{hide} and (grep /^$col$/, @{$self->{hide}}));
return 0;
}

Has anyone used this approach to hide the display of hidden fields and timestamps fields. I thought this might be usefully to many users as most would not like to display hidden fields and timestamps. Moreover, this would be a much cleaner solution to this whole problem of hiding the Hidden Fields and timestamps, in comparison to template customization!!

I would appreciate if someone can help me in leveraging sub _skip() and other settings given above to achieve this, or share with us your experience if have tried this approach.

Thanks

TIF