Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Show relational field

Quote Reply
Show relational field
Hello

great work on dbman sql

Question

How can I show the related field in the search results?

Fábio
Quote Reply
Re: [assombracao] Show relational field In reply to
Hi,

You can use <%Dbsql::Relation::HTML::generate_description('primary_table', 'foreign_key', 'description_field')%> in your template to get the description of foreign key.

E.g: The Book table is related to Category table on CatID which is the foreign key field, so the command should be:

<%Dbsql::Relation::HTML::generate_description('Category', 'CatID', 'CatName')%>

Hope thats help.

TheStone.

B.
Quote Reply
Re: [TheStone] Show relational field In reply to
Hi, I used

<%table.field%> with the relational "q" in the url and it worked for the results

<%marcas_veiculos.nome_marca%>


But I´m triing to do the same for the modify form and it isn´t working

and this doesn´t worked

<%Dbsql::Relation::HTML::generate_description('primary_table', 'foreign_key', 'description_field')%>

Fábio
Quote Reply
Re: [assombracao] Show relational field In reply to
DBMan SQL does not support to add/modify records within multiple tables at the same time, so you can not add/modify records in related table by using <%table.field%> tags which is used for viewing records only.

TheStone.

B.
Quote Reply
Re: [TheStone] Show relational field In reply to
Hello theStone

I dont want to add or modify the record in the related table

only the ID in the maintable

I want the related field to show the name of the model instead of the ID, for the select form
Quote Reply
Re: [assombracao] Show relational field In reply to
You should check the 'Create a dropdown from' option and select field which will be displayed on add/modify form when adding/modifing a relation ( Goto Admin - Relationship - Show - hit a bar to edit ).

TheStone.

B.
Quote Reply
Re: [TheStone] Show relational field In reply to
It work that way

but I want to customize the template

Fábio
Quote Reply
Re: [assombracao] Show relational field In reply to
You can use <%Dbsql::Relation::HTML::generate_full_down('primary_table', 'related_table')%> tag to generate the drop down menu.

TheStone.

B.
Quote Reply
Re: [TheStone] Show relational field In reply to
Ok,

and I´m using a javascript combobox to select only the models of some factory, and I want to display only the selected item, to put it in the javascript code

We are almost there

Thank´s for helpping me

Fábio
Quote Reply
Re: [assombracao] Show relational field In reply to
I am not completely sure what you want, but the following Template global might help:
Code:
sub {
#-------------------------------------------------------------------
# Get description field from table
# $table : table, $id: pk; $desc: description field
#
my ($table, $id, $desc) = @_;
($table and $id and $desc) or return;
my $tags = GT::Template->tags;
my $home = $tags->{home};
my $rs = $home->{sql}->table($table)->get($id,[$desc]);
return $rs->{$desc};
}
Call it with the table name, the id of the entry en the column name you need like this
Code:
<%show_description('Users',$userid,'fullname')%>
Is that what you need?

Jasper

BTW Why did you repost this entry in a new thread?

http://www.bookings.org
Quote Reply
Re: [jaspercram] Show relational field In reply to
Hello Jasper!

Thanks! is exactly that what I needed!!

Sorry for the repost of the thread
Quote Reply
Re: [TheStone] Show relational field In reply to
In Reply To:
You can use <%Dbsql::Relation::HTML::generate_full_down('primary_table', 'related_table')%> tag to generate the drop down menu.

TheStone.


About this item, it´s not geting the current value from the modify form, any ideas?
Quote Reply
Re: [assombracao] Show relational field In reply to
In Reply To:
In Reply To:
You can use <%Dbsql::Relation::HTML::generate_full_down('primary_table', 'related_table')%> tag to generate the drop down menu.

TheStone.


About this item, it´s not geting the current value from the modify form, any ideas?


Ah, I´m using customized templates

Fábio