Skip to content

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

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy