Closed jmros closed 6 years ago
You have to remove
protected $parentAssociationMapping = 'factura';
and add the name of your child as a second argument here:
calls:
- [ addChild, ['@admin.factura_detalle', 'NAME_OF_PARENT']]
I love you!!!!! really tnks!!!!
@kunicmarko20 we should add an yaml example in the docs, too
Yes, that would make it easier for people.
yes, the website documentation doesn't works.
i found this in stack oveflow:
calls:
- [ addChild, ['@admin.factura_detalle', 'NAME_OF_CHILD']]
EDIT by OskarStark:
You need to use NAME_OF_PARENT
!!!
calls:
- [ addChild, ['@admin.factura_detalle', 'NAME_OF_PARENT']]
@jmros can you please make a PR to fix the docs?
I created PR #5115
Is $parentAssociationMapping
still necessary now that the parent relationship is defined in the addChild
call?
If it's not, maybe it should be removed from the docs too? It's still in VideoAdmin and was confusing for me.
Yes, it should be removed, can you make a PR, please?
Thanks for your Feedback
Sure. simple enough pr. Will do it tmrw or wknd between work
FYI, haven't forgotten this. Just been busy. Will update when I can.
Thank you for coming back 👍 In the meantime I fixe this small docs!
Sorry I couldn't help more/sooner. Would love to help more though.
Sorry I couldn't help more/sooner. Would love to help more though.
No problem, every help is appreciated 👍
@quazardous works for me. your association is wrong?
@haivala not the association but something is wrong with my entity. I've tested with a FooBar entity from scratch it's OK, Sorry for the noise. I've delete the post
You have to remove
protected $parentAssociationMapping = 'factura';
and add the name of your child as a second argument here:
calls: - [ addChild, ['@admin.factura_detalle', 'NAME_OF_PARENT']]
Sorry for the noise, is this possible with SonataAutoConfigureBundle? cause removing $parentAssociationMapping looses parent.
@dotoree you will have to use annotation https://github.com/kunicmarko20/SonataAutoConfigureBundle#adminoptions, there is a children optiom there
@dotoree you will have to use annotation https://github.com/kunicmarko20/SonataAutoConfigureBundle#adminoptions, there is a children optiom there
@kunicmarko20: Already using children annotation, but does not work without $parentAssociationMapping
in child admin. Here is my code:
/**
* @Sonata\AdminOptions(
* label="label_authors",
* showMosaicButton=false,
* group="label_authors",
* icon="<i class='fa fa-user-circle-o'></i>",
* onTop=true,
* children={"App\Admin\AuthorHasPaymentAdmin"}
* )
*/
final class AuthorAdmin extends AbstractAdmin
{
}
/**
* @Sonata\AdminOptions(
* label="label_author_has_payment",
* showInDashboard=false,
* )
*/
final class AuthorHasPaymentAdmin extends AbstractAdmin
{
protected $parentAssociationMapping = 'author';
}
The only way I can solve this right now is by removing $parentAssociationMapping
and adding preValidate
to child admin:
public function preValidate($payment)
{
if ($this->getParent()) {
$payment->setAuthor($this->getParent()->getSubject());
}
}
hello, i know i am very late to the party. have an issue with this feature as before i could add unidirectional references with the addChild method (do not have the parent field). so how can this be done now? only the cross table knows the connection between parent and children. but i dont want an extra admin for the crosstable as you might want with sortable references.
I have 2 classes:
In the services.yml
If i do de official documentation instructions it not works. https://sonata-project.org/bundles/admin/3-x/doc/reference/child_admin.html
I need to add " - [ addChild, ['@admin.factura_detalle']]" but this is not compatible wihit symfony 4.0