This topic is locked

SetFieldLabel for child table

10/31/2024 5:36:52 AM
PHPRunner General questions
D
druck281 author

I have a field in my Master table called 'UnitLabel' and my goal is to use that string as the label for a column in a child table that is displayed on the Edit/View pages of the master table. Currently, on the Edit and view pages, I am setting a session variable in the 'Before Display' event

$_SESSION['UnitLabel']=$values['UnitLabel'];

On the child table in the 'After Table Initialized' event, I am using the Labels API

//If the Unit Label is set in the EqList record, display this value as the label on the child table.
if ($_SESSION['UnitLabel']) {
Labels::setFieldLabel("psn_EqListHours", "UnitAdjustment", $_SESSION['UnitLabel']);
}

This code works but the session variable is set after the child table intializes so the label doesn't appear correctly until I refresh the page. Is there an alternate way to fetch that Label from the master table that will have it available before the child table initializes?

img alt

D
druck281 author 10/31/2024

As an alternate, I also tried getting the master record from the 'After Table Initialized' event of the child table and setting the label from that.

$masterData = $pageObject->getMasterRecord();

Labels::setFieldLabel("psn_EqListHours", "UnitAdjustment", $masterData["UnitLabel"]);

This approach throws an error 'Uncaught Error: Call to a member function getMasterRecord() on null'