Skip to content

Add addDisplayOnPage in src/Field/FieldTrait.php #6318

@ceponcet

Description

@ceponcet

Short description of what this feature will allow to do:
Add addDisplayOnPage(string $pageName) in src/Field/FieldTrait.php

Adding the addDisplayOnPage(string $pageName) method to the src/Field/FieldTrait.php trait allows adding a field to a "page" other than EDIT INDEX DETAIL NEW. These other pages can be, for example, CSV or WHATEVER.

Example of how to use this feature

#src/Controller/Admin/MyCrudController.php
[...]
public function configureFields(string $pageName): iterable
{
      yield TextField::new('field')
            ->addDisplayOnPage("CSV")
            ->hideOnIndex()->hideOnForm()->hideOnDetail();
}

# And in another method, We retrieve only fields of CSV PAGE
public function export(AdminContext $context): Response
{
     //
        $context->getCrud()->setPageName("CSV");
     //
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions