Relationship/Transient Not Applied In New Related Record
Posted: Mon Feb 22, 2010 1:18 am
You can create a new Adult record, and a new Student record. You can link them as existing records. However, if you try to create a new Adult record from the New Related Record button in the Student table, it is created, but not linked. Additionally, the transient Role field is not saved in the new Adult (which may, in fact, be the cause of the linking issue...)
/tables/Student/relationships.ini
/tables/Student/valuelists.ini
/tables/Adult/relationships.ini
/tables/Adult/valuelists.ini
The Adult and Student tables are (supposed to) only be associated if the transient Role field includes RoleID 5, which is the Parent role. When you create a New Related Record, it doesn't seem to save the content of transient Role, which (I think) is why it doesn't relate properly.
Here's the set-up for the Role field.
/tables/Adult/fields.ini (excerpt)
/tables/Adult/valuelists.ini (excerpt)
/tables/Role/relationships.ini
I think that's about it. Does the New Related Record form not work with transient fields, perhaps? Hmm.
Thanks.
/tables/Student/relationships.ini
- Code: Select all
[Parents]
adult.AdultID = family.AdultID
family.StudentID = "$StudentID"
vocabulary:existing = "Parents"
[Class]
class.ClassID = "$Class"
action:visible = 0
[Attendance]
attendance.Student = "$StudentID"
[Involvement]
production.ProductionID = studentinvolvement.ProductionID
studentinvolvement.StudentID = "$StudentID"
[Waiting List]
waitinglist.ListID = "$WaitingList"
action:visible = 0
/tables/Student/valuelists.ini
- Code: Select all
[Statuses]
S = Student
A = Associate
[Payments]
dd = Direct Debit
cc = Credit Card
c = Cash
cqe = Cheque
[Enrolments]
WL = Waiting List
E = Enrolled
WD = Withdrawn
[Classes]
__sql__ = "SELECT ClassID, Name FROM class ORDER BY Name"
[Lists]
__sql__ = "SELECT ListID, Year FROM waitinglist ORDER BY Year"
/tables/Adult/relationships.ini
- Code: Select all
[Children]
family.AdultID = "$AdultID"
student.StudentID = family.StudentID
action:condition = "mysql_fetch_row(mysql_query('SELECT * FROM AdultRole WHERE AdultID = '.$record->val('AdultID').' AND RoleID = 5'))"
[Classes]
classes.AdultID = "$AdultID"
class.ClassID = classes.ClassID
action:condition = "mysql_fetch_row(mysql_query('SELECT * FROM AdultRole WHERE AdultID = '.$record->val('AdultID').' AND RoleID = 3'))"
[Roles]
adultrole.AdultID = "$AdultID"
role.RoleID = adultrole.RoleID
action:visible = 0
[Involvement]
adultinvolvement.AdultID = "$AdultID"
production.ProductionID = adultinvolvement.ProductionID
[Attendance]
adultmeeting.AdultID = "$AdultID"
adultmeeting.MeetingID = meeting.MeetingID
/tables/Adult/valuelists.ini
- Code: Select all
[Roles]
__sql__ = "SELECT RoleID, Name FROM role ORDER BY Name"
[Statuses]
S = Senior
A = Assistant
T = Trainee
[Tutors]
__sql__ = "SELECT Adult.AdultID, CONCAT(LName, ', ', FName) FROM adult INNER JOIN AdultRole ON Adult.AdultID = AdultRole.AdultID AND AdultRole.RoleID = 3"
[Parents]
__sql__ = "SELECT Adult.AdultID, CONCAT(LName, ', ', FName) FROM adult INNER JOIN AdultRole ON Adult.AdultID = AdultRole.AdultID AND AdultRole.RoleID = 5"
The Adult and Student tables are (supposed to) only be associated if the transient Role field includes RoleID 5, which is the Parent role. When you create a New Related Record, it doesn't seem to save the content of transient Role, which (I think) is why it doesn't relate properly.
Here's the set-up for the Role field.
/tables/Adult/fields.ini (excerpt)
- Code: Select all
[Role]
widget:type = checkbox
transient = 1
relationship = Roles
order = 100
visibility:list = visible
/tables/Adult/valuelists.ini (excerpt)
- Code: Select all
[Roles]
__sql__ = "SELECT RoleID, Name FROM role ORDER BY Name"
/tables/Role/relationships.ini
- Code: Select all
[Adults]
adultrole.RoleID = "$RoleID"
adult.AdultID = adultrole.AdultID
I think that's about it. Does the New Related Record form not work with transient fields, perhaps? Hmm.
Thanks.