Hi,
I have a many to many relationships + a one-to-many relationships between a personne and telephone table. Basically I want to show a personne with a preferred telephone and allow the personne to select from his list of telephones which one should be shown in the list view (as pref tel). so I have the following setup but doesn't work as expected.
tables setup:
personne=
id (primary)
fname
lname
tel_id
personneTelephone
pers_id (primary)
tel_id (primary)
telephone
id (primary)
number
type
in my tables/personne directory I have put relationships.ini file as follow and I do see the 'telephones' tab and the list of telephone associated to a given personne
relationships.ini=
[telephones]
__sql__ = "SELECT telephone.number,telephone.type
FROM personneTelephone pt
INNER JOIN telephone t
ON pt.tel_id = t.id
WHERE pt.pers_id = '$id'"
so in my personne table list I now see in the detail view a tab called 'telephones' where I can see all related telephone for that given personne.
Now how would you do to see in the edit tab for that given personne the list of telephone so you could allocated one telephone id as the preferred telephone for that given personne.
I am trying with valuelists.ini and fields.ini but I can't get it. I either have only an id telephone or a full list of telephone number stored in the DB ...
in my tables/personne directory I have put a valuelists.ini and fields.ini files with following setup but this where I don't have it working ... see below
valuelists.ini=
[telpref]
__sql__ = "select t.id,t.number
FROM telephone t
LEFT JOIN personneTelephone pt
ON pt.tel_id = t.id
WHERE pt.pers_id = '$id'"
fields.ini=
[id]
visibility:list = hidden
[lastname]
widget:label = "Nom "
[firstname]
widget:label = "Prénom "
[tel_id]
widget:label = "Téléphone préferré "
widget:type = select
vocabulary = telpref
Now the result is that I only got the id number of the telephone (not the number) and when editing the record the select field only shows the preferred id (not the list of telephone associated for this personne) and I have about 3 tel number in my db.
thanks for your help in advance.
Fabrice,