Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Form][2.8] FormFactory::create ignores getBlockPrefix when generating the name #15760

Closed
@craue

Description

@craue

Form type:

use Symfony\Component\Form\AbstractType;

class ModifySettingsForm extends AbstractType {

    public function getBlockPrefix() {
        return 'modifySettings';
    }

}

Now calling

  1. $this->get('form.factory')->createNamed('modifySettings', ModifySettingsForm::class)
  2. $this->createForm(ModifySettingsForm::class)

in a controller leads to different results when rendering the template. While in the 1st case the form name actually is modifySettings, it is modify_settings_form in the 2nd case, so the block prefix is ignored and the name is generated using the class name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions