Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is it possible to use entitytype #70

Open
t-n-y opened this issue Mar 21, 2024 · 3 comments
Open

is it possible to use entitytype #70

t-n-y opened this issue Mar 21, 2024 · 3 comments

Comments

@t-n-y
Copy link

t-n-y commented Mar 21, 2024

Is it possible to use an entityType, to set a collection of other entity in the configuration ?

I am looking a way to do that but can't find any exemple

@delyriand
Copy link
Member

Hi @t-n-y,

Yes, it's possible to use the EntityType::class in your form type.
You just need to define a data transformer.

Example with a "Page" entity from another beautiful plugin:

$this->addWithDefaultCheckbox(
    $builder, 'page', EntityType::class, [
        'class' => Page::class,
        'choice_label' => 'title',
       // ...
    ]
);

$pageToCodeTransformer = new ReversedTransformer(new ResourceToIdentifierTransformer($this->pageRepository, 'code'));
$builder->get('page')->addModelTransformer($pageToCodeTransformer);

@t-n-y
Copy link
Author

t-n-y commented Mar 21, 2024

Hi @delyriand,

Thank you for the quick response.
I'll try to implement that. So if i understand well, you re finally saving the code string in the text_value field ?

@delyriand
Copy link
Member

@t-n-y, That's right!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants