Skip to content

Conversation

@IndraGunawan
Copy link
Contributor

@IndraGunawan IndraGunawan commented Feb 29, 2024

when generating form with EntityType, the indentation of options_code looks wrong

below example is Foo <-- ManyToMany --> Bar
Before

<?php

class BarType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('name')
            ->add('Foo', EntityType::class, [
                'class' => Foo::class,
'choice_label' => 'id',
'multiple' => true,
            ])
        ;
    }

    // ....
}

After

<?php

class BarType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('name')
            ->add('Foo', EntityType::class, [
                'class' => Foo::class,
                'choice_label' => 'id',
                'multiple' => true,
            ])
        ;
    }

    // ....
}

@jrushlow jrushlow added Bug Bug Fix Unconfirmed Status: Needs Review Needs to be reviewed labels Mar 1, 2024
}

$ignoreEnv = str_contains(strtolower(\PHP_OS), 'win') ? 'set PHP_CS_FIXER_IGNORE_ENV=1&' : 'PHP_CS_FIXER_IGNORE_ENV=1 ';
$ignoreEnv = str_starts_with(strtolower(\PHP_OS), 'win') ? 'set PHP_CS_FIXER_IGNORE_ENV=1& ' : 'PHP_CS_FIXER_IGNORE_ENV=1 ';
Copy link
Contributor Author

@IndraGunawan IndraGunawan Mar 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jrushlow i also made changes on this as these changes didn't seem right https://github.com/symfony/maker-bundle/pull/1435/files#diff-63196606ee883ed9470b1dfceed2cc28540986c0180afdb82e274812fa4690daR59

using str_contains, it was affect Darwin as well

Copy link
Collaborator

@jrushlow jrushlow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, Thank you @IndraGunawan

@jrushlow jrushlow added Status: Reviewed Has been reviewed by a maintainer and removed Unconfirmed Status: Needs Review Needs to be reviewed labels Mar 4, 2024
@jrushlow jrushlow merged commit 7706a2f into symfony:main Mar 4, 2024
@jrushlow jrushlow mentioned this pull request Mar 4, 2024
@IndraGunawan IndraGunawan deleted the fix-form-options-indent branch March 4, 2024 06:49
kbond added a commit that referenced this pull request Mar 26, 2025
This PR was merged into the 1.x-dev branch.

Discussion
----------

Fix indentation of options_code

Similar to #1469 but doesn't rely on any CS fixer.

Note that using PHP_EOL was wrong: this constant is meant to be used ONLY when outputting something on a terminal. NOT when dealing with new lines in files.

Commits
-------

91b7ce0 Fix indentation of options_code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Bug Fix Status: Reviewed Has been reviewed by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants