Closed paugnu closed 3 years ago
The method that changes the grid name into an event name suffix takes care of that:
private function getGridNameEventSuffix(string $gridName): string
{
return strtolower(preg_replace('/[^[:alpha:]]+/', '_', $gridName));
}
That will replace -
with _
In your case the PHP event observer should be for the event hyva_grid_column_definition_build_after_product_grid
PS: Thanks for opening the issue, I've updated the docs with this information.
Hi,
I created a new grid with the name product-grid. Afterwards, I wanted to create an event to modify the columns.
As per explained here: https://github.com/hyva-themes/magento2-hyva-admin/blob/main/doc/2.%20API%20Reference/Event%20Reference/Grid%20Column%20Definition%20Build%20After%20Event.md
My event name would be:
hyva_grid_column_definition_build_after_product-grid
But if I try to use hyva_grid_column_definition_build_after_product-grid as a event name:
This will throw an error:
Element 'event', attribute 'name': [facet 'pattern'] The value 'hyva_grid_column_definition_build_after_product-grid' is not accepted by the pattern '[a-zA-Z0-9_]+'.
Element 'event', attribute 'name': 'hyva_grid_column_definition_build_after_product-grid' is not a valid value of the atomic type 'eventName'.
Some ideas...
-
into_
when creating passing the grid name to the dispatcher, but then we should also explain in the doc that the event name would be the grid name but with '_' instead of '-'