Skip to content

[EA3][Need Help] Nested crud forms #4766

@furang

Description

@furang

Hello friends.
I have two entities Order and Product (One-to-Many relation).
How should I adjust Field for this relation so I can add new Products while creating Order
Something like this
Screenshot from 2021-10-27 17-01-49
I managed to create this form using CollectionField

CollectionField::new('products')->setEntryType(ProductsEntryType::class);

with CrudFormType

// ProductsEntryType
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $entity = $this->entityFactory->create(ProductCrudController::getEntityFqcn());
        $this->entityFactory->processFields($entity, FieldCollection::new([TextField::new('description'), TextField::new('price')]));

        $builder->add(
            'products',
            CrudFormType::class,
            [
                'entityDto' => $entity,
            ]
        );
    }

But I need to pass fields from ProductCrudController with permissions.
Can someone please help me to render product(s) form(s) inside order form with storing all data?
Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions