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

Bug Fix : FormPanel with AssociationField render as embedded form issue #5767

Open
wants to merge 1 commit into
base: 4.x
Choose a base branch
from

Conversation

daday-andry
Copy link

This is a bug fix of issue #5596

Bug Description

An error occured in the template when trying to render as ambedded form an AssociationField under EaFormPanelType.

To reproduce

public function configureFields(string $pageName): iterable {
    return  [
        FormField::addPanel('My Panel title'),
        AssociationField::new('propertyName')->renderAsEmbeddedForm(EmbedeedCrunController::class),
    ]
}

@daday-andry daday-andry changed the title Bug Fix Bug : FormPanelType with AssociationField render as embedded form issue May 25, 2023
@daday-andry daday-andry changed the title Bug : FormPanelType with AssociationField render as embedded form issue Bug Fix : FormPanel with AssociationField render as embedded form issue May 25, 2023
@featuriz
Copy link
Contributor

featuriz commented Jun 15, 2023

6c27330
This fix works for me.

@daday-andry
Copy link
Author

Hi, @javiereguiluz ,
according the file changes , what is the reason of PHP-CS-Fixer test failure ?
Thank's

@fonpacific
Copy link

6c27330 This fix works for me.

This 'kinda' works for me too. Only issue I have is that it screws up the columns set with ->setColumns() in embedded form.
This is the relevant part in my "main" CRUD ClientCrudController:

public function configureFields(string $pageName): iterable
{
    ...
    yield FormField::addPanel('panel 1');
    yield AssociationField::new('owner', false)
        ->renderAsEmbeddedForm(OwnerDataCrudController::class, 'newOwnerPage', 'editOwnerPage')
        ->onlyOnForms();
    ...
}

And this is a portion of OwnerDataCrudController:

public function configureFields(string $pageName): iterable
{
    ...
    yield TextField::new('firstName', 'Nome')
        ->setRequired($pageName === 'newOwnerPage')
        ->setColumns('col-12 col-lg-4');

    yield TextField::new('lastName', 'Cognome')
        ->setRequired($pageName === 'newOwnerPage')
        ->setColumns('col-12 col-lg-4');

    yield TextField::new('fiscalCode', 'Codice fiscale')
        ->setRequired($pageName === 'newOwnerPage')
        ->setColumns('col-12 col-lg-4');
    ...

After the aforementioned fix, the fileds are displayed in a single column.
A fix could be to add css class "row" in the <div class="form-widget"> inside <div class="form-panel">

image

@fonpacific
Copy link

Another way to deal with the 'one column' issue is via SCSS:

.form-panel-header + .form-panel-body .field-association > .form-widget {
    --bs-gutter-x: 1.5rem;
    --bs-gutter-y: 0;
    display: flex;
    flex-wrap: wrap;
    margin-left: calc(var(--bs-gutter-x)*-.5);
    margin-right: calc(var(--bs-gutter-x)*-.5);
    margin-top: calc(var(--bs-gutter-y)*-1);

    > * {
        flex-shrink: 0;
        margin-top: var(--bs-gutter-y);
        max-width: 100%;
        padding-left: calc(var(--bs-gutter-x)*.5);
        padding-right: calc(var(--bs-gutter-x)*.5);
    }
}

This code restores the correct column disposition (is the css bootstrap uses for .row class.

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

Successfully merging this pull request may close these issues.

3 participants