When I query the Model service for a ChannelEntry, the grid fields show as empty. However, if I query for a ChannelEntryVersion, that does have grid data under “version_data”. But after publishing the entry, I need to look at the ChannelEntry (as that’s now the latest) but I cannot find any grid data in there. Why would it be empty for an entry?
The ChannelEntryVersion->version_data->field_id_8 has the grid rows, but no where in the ChannelEntry are the grid rows (I output the var_dump( $entry ) to a file and the grid data’s not in there).
All I see in the entry is “field_id_8” => ” “, “field_ft_8” = “xhtml”.
How do I get a grid field’s data from the model service?
$entry = ee( "Model" )->get( "ChannelEntry" )
->filter( "channel_id", $channelId )
->filter( "entry_id", $entryId )
->filter( "status", "IN", array( "open" ) )
->first();
EDIT:
If I do the query with “Versions”, then I find that data under $entry->Versions[ 0 ]->version_data. Is that correct? Is that the latest, published data?
$entry = ee( "Model" )->get( "ChannelEntry" )
->with( "Versions" )
->filter( "channel_id", $channelId )
->filter( "entry_id", $entryId )
->filter( "status", "IN", array( "open" ) )
->first();
//Grid data now in here:
$entry->Versions[ 0 ]->version_data
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.