// "field1###' AND ..." -> array("field1", "' AND ...")
$whereClauseSubParts = explode('###', $value, 2);
// @todo: Throw exception if there is no value? What happens for NEW records?
- $rowFieldValue = $result['databaseRow'][$whereClauseSubParts[0]];
+ $databaseRowKey = empty($result['flexParentDatabaseRow']) ? 'databaseRow' : 'flexParentDatabaseRow';
+ $rowFieldValue = isset($result[$databaseRowKey][$whereClauseSubParts[0]]) ? $result[$databaseRowKey][$whereClauseSubParts[0]] : '';
if (is_array($rowFieldValue)) {
// If a select or group field is used here, it may have been processed already and
// is now an array. Use first selected value in this case.
'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND fTable.title=\'rowFieldValue\'',
[],
],
+ 'replace REC_FIELD within FlexForm' => [
+ 'AND fTable.title=###REC_FIELD_rowFieldFlexForm###',
+ 'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND fTable.title=\'rowFieldFlexFormValue\'',
+ [
+ 'databaseRow' => [
+ 'rowFieldThree' => [
+ 0 => 'rowFieldThreeValue'
+ ]
+ ],
+ 'flexParentDatabaseRow' => [
+ 'rowFieldFlexForm' => [
+ 0 => 'rowFieldFlexFormValue'
+ ]
+ ],
+ ],
+ ],
'replace REC_FIELD fullQuote' => [
'AND fTable.title=###REC_FIELD_rowField###',
'pages.uid=fTable.pid AND pages.deleted=0 AND 1=1 AND fTable.title=\'rowFieldValue\'',