Closed Kreyu closed 1 month ago
I can't seem to use CollectionColumnType:
->addColumn('rifeProgramFrequencies', CollectionColumnType::class, [
'entry_options' => [
'formatter' => function (RifeProgramFrequency $rifeProgramFrequency): string {
return $rifeProgramFrequency->getFrequency();
},
],
])
I can't seem to use CollectionColumnType:
->addColumn('rifeProgramFrequencies', CollectionColumnType::class, [ 'entry_options' => [ 'formatter' => function (RifeProgramFrequency $rifeProgramFrequency): string { return $rifeProgramFrequency->getFrequency(); }, ], ])
Hey @nicodemuz, try setting a property path inside the entry_options
that will direct the bundle on which property should be displayed:
->addColumn('rifeProgramFrequencies', CollectionColumnType::class, [
'entry_options' => [
'property_path' => 'frequency',
],
])
Because the CollectionColumnType
creates "fake" columns inside itself for each entry in the collection, the property path will default to column name, which in this case would be 0, 1, 2, etc. (index of each entry).
The formatter
callback is applied on the data retrieved from the entity, so it's later in the process. Alternatively, you can use the getter
instead of property path:
->addColumn('rifeProgramFrequencies', CollectionColumnType::class, [
'entry_options' => [
'getter' => function (RifeProgramFrequency $rifeProgramFrequency): string {
return $rifeProgramFrequency->getFrequency();
},
],
])
ActionsColumnType
now contains a valid reference to their data tableCollectionColumnType
now contains a valid reference to their data table, and each nested column is now named by their index (0, 1, 2, etc.) instead of generic__name__
PRE_INITIALIZE
andPOST_INITIALIZE