Relationship/Transient Not Applied In New Related Record
Archived from the Xataface Users forum.
00Davo — 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
- 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.
shannah — Tue Feb 23, 2010 10:17 am
Can you also post the SQL def for the relevant table so I can set up a test case in my server.
00Davo — Tue Feb 23, 2010 1:03 pm
- Code: Select all
- `` CREATE TABLE
adult(
AdultIDint(11) NOT NULL AUTO_INCREMENT,
LNamevarchar(50) NOT NULL,
FNamevarchar(50) NOT NULL,
HouseNovarchar(10) DEFAULT NULL,
Streetvarchar(50) DEFAULT NULL,
Suburbvarchar(50) DEFAULT NULL,
Postcodeint(11) DEFAULT NULL,
Phonevarchar(20) DEFAULT NULL,
Mobilevarchar(20) DEFAULT NULL,
Emailvarchar(50) DEFAULT NULL,
Email2varchar(50) DEFAULT NULL,
YPTReceiptNoint(11) DEFAULT NULL,
LSPReceiptNoint(11) DEFAULT NULL,
YPTFeePaiddouble DEFAULT NULL,
LSPFeePaiddouble DEFAULT NULL,
Involvementtext,
EOItinyint(1) DEFAULT NULL,
Contracttinyint(1) DEFAULT NULL,
ATOtinyint(1) DEFAULT NULL,
EDFtinyint(1) DEFAULT NULL,
Statusenum(‘S’,’A’,’T’) DEFAULT NULL,
Photostinyint(1) DEFAULT NULL,
PRIMARY KEY (AdultID)
) ENGINE=InnoDB AUTO_INCREMENT=194 DEFAULT CHARSET=latin1;CREATE TABLE
adultrole(
AdultRoleIDint(11) NOT NULL AUTO_INCREMENT,
AdultIDint(11) DEFAULT NULL,
RoleIDint(11) DEFAULT NULL,
PRIMARY KEY (AdultRoleID)
) ENGINE=MyISAM AUTO_INCREMENT=118 DEFAULT CHARSET=latin1;CREATE TABLE
family(
FamilyIDint(11) NOT NULL AUTO_INCREMENT,
AdultIDint(11) DEFAULT NULL,
StudentIDint(11) DEFAULT NULL,
PRIMARY KEY (FamilyID)
) ENGINE=MyISAM AUTO_INCREMENT=198 DEFAULT CHARSET=latin1;/*Table structure for table
role*/DROP TABLE IF EXISTS
role;CREATE TABLE
role(
RoleIDint(11) NOT NULL AUTO_INCREMENT,
Namevarchar(50) DEFAULT NULL,
PRIMARY KEY (RoleID)
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;/*Data for the table
role*/insert into
role(RoleID,Name) values (1,’LSP Member’),(2,’Committee Member’),(3,’Tutor’),(4,’Patron’),(5,’Parent’),(6,’YPT Member’);CREATE TABLE
student(
StudentIDint(11) NOT NULL AUTO_INCREMENT,
LNamevarchar(50) DEFAULT NULL,
FNamevarchar(50) DEFAULT NULL,
DOBdate DEFAULT NULL,
HouseNovarchar(10) DEFAULT NULL,
Streetvarchar(50) DEFAULT NULL,
Suburbvarchar(50) DEFAULT NULL,
Postcodeint(11) DEFAULT NULL,
Phonevarchar(20) DEFAULT NULL,
Mobilevarchar(20) DEFAULT NULL,
Emailvarchar(50) DEFAULT NULL,
Email2varchar(50) DEFAULT NULL,
EnrolmentStatusenum(‘WL’,’E’,’WD’) DEFAULT NULL,
SchoolYearint(4) DEFAULT NULL,
WaitingListint(11) DEFAULT NULL,
WaitingListPlaceint(11) DEFAULT NULL,
WaitingListDatedate DEFAULT NULL,
ClassPlacementDatedate DEFAULT NULL,
ClassPlacementAcceptancetinyint(1) DEFAULT NULL,
ClassEnrolmentDatedate DEFAULT NULL,
EnrolmentYearint(4) DEFAULT NULL,
Classint(11) DEFAULT NULL,
Statusenum(‘S’,’A’) DEFAULT NULL,
FeesPaid1double DEFAULT NULL,
ReceiptNo1int(11) DEFAULT NULL,
PaymentMethod1enum(‘dd’,’cc’,’c’,’cqe’) DEFAULT NULL,
FeesPaid2double DEFAULT NULL,
ReceiptNo2int(11) DEFAULT NULL,
PaymentMethod2enum(‘dd’,’cc’,’c’,’cqe’) DEFAULT NULL,
Productionstext,
Involvementtext,
Photostinyint(1) DEFAULT NULL,
Medicaltinyint(1) DEFAULT NULL,
MedDetailstext,
PRIMARY KEY (StudentID)
) ENGINE=InnoDB AUTO_INCREMENT=251 DEFAULT CHARSET=latin1; ``
There we go. I think that’s all the relevant tables. Note that I’ve included data for the Role table, ‘cause the Role IDs are hardcoded in the .ini files.
00Davo — Tue Apr 06, 2010 4:58 pm
*bump* Still having this issue.
shannah — Thu Apr 08, 2010 9:58 am
Sorry… been really busy and haven’t had a chance to try this out. Perhaps over the weekend I’ll get some time to look into it…