A customer pointed out that when using the Live Preview a Relationship field inside of Bloqs does not parse correctly. I have a feeling its b/c the conditionals in this method that are testing to see if it is Grid are not evaluating the way I need them to b/c… well… Bloqs isn’t exactly grid (though they share many things).
I haven’t actually tested this to get it working, but I suspect that a hook just after the opening of the LivePreview check may suffice in what I need it to do. If I were to stub out a working example would EL be open to adding a hook?
relationship_model.php line 196
private function overrideWithPreviewData($result, $type, $fluid_field_data_id)
{
if (ee('LivePreview')->hasEntryData())
{
//
// Possible to add a hook here that can return data and bypass the following stuff?
//
$data = ee('LivePreview')->getEntryData();
$entry_id = $data['entry_id'];
$channel = ee('Model')->get('Channel', $data['channel_id'])->first();
$all_fields = $channel->getAllCustomFields();
$rel_fields = $all_fields->filter(function($field)
{
return $field->field_type == 'relationship';
})->pluck('field_id');
if (/*true ||*/ $type == self::GRID)
{
$grid_field_ids = [];
foreach ($all_fields as $field)
{
if ($field->field_type == 'grid'/* || $field->field_type == 'bloqs'*/)
{
$grid_field_ids[$field->getId()] = TRUE;
}
elseif ($field->field_type == 'fluid_field')
{
if ( ! empty($field->field_settings['field_channel_fields']))
{
$fields = ee('Model')->get('ChannelField')
->fields('field_id')
->filter('field_id', 'IN', $field->field_settings['field_channel_fields'])
->filter('field_type', 'grid')
->all();
foreach ($fields as $grid_field)
{
$grid_field_ids[$grid_field->getId()] = TRUE;
}
}
}
}
return $this->overrideGridRelationships($result, $data, array_keys($grid_field_ids), $fluid_field_data_id);
}
Hi Brian, sorry for the delay! Wanted to discuss it internally first. Sounds like we’d be fine with a hook since there are already hooks to alter relationship stuff, but we’d want to see if you could put the hook towards the very end right before we return $result
. Let us know if that works.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.