Form icon indicating copy to clipboard operation
Form copied to clipboard

Could not load type "Symfony\Component\Form\Extension\Core\Type\HiddenType"

Open emirii opened this issue 9 years ago • 6 comments

In Symfony 2.7.10/2.7.9 the latest update breaks, with any form type using hidden_entity:

Could not load type "Symfony\Component\Form\Extension\Core\Type\HiddenType"

This commit here: https://github.com/LRotherfield/Form/commit/b9cf8349cf9f45545af2f7f1c16a33efe23d2a71

    /**
     * Set the parent form type to Symfony core HiddenType
     *
     * TODO: when drop Symfony 2.x support, add use statement above
     *       for HiddenType core class and return HiddenType::class
     *       here instead of path string
     *
     * @return string
     */
    public function getParent()
    {
        return 'hidden';
    }

I just change getParent to return 'hidden' instead of the class name and it works again. Not sure what else to do to help... but just a heads up.

emirii avatar Feb 29 '16 19:02 emirii

Thanks for the report, I will see if I can sort this.

LRotherfield avatar Feb 29 '16 19:02 LRotherfield

I can confirm this error in Symfony 2.6 too.

Fast workaround:

  1. create class extending Lrotherfield\Component\Form\Type\HiddenEntityType and add inside
public function getParent()
{
    return 'hidden';
}
  1. replace class in services.yml for lrotherfield.form.type.hidden_entity for this created in 1)

Works for now, but it should be configurable somehow

giero avatar Mar 04 '16 15:03 giero

The fix is to revert to version 1.1.2. But since versions 1.1.1 and 1.1.2 are invalid, and so are not propagating to packagist, you cannot use a version identifier in composer. Instead: "lrotherfield/form" : "dev-master#799597f", Also the next version should be a major one (either 1.2 or 2.0), so that it's clear that it breaks compatibility with Symfony versions <= 2.7.

djcvijic avatar Mar 31 '16 10:03 djcvijic

@djcvijic I have pushed a tag v2.0.0 as a release for symfony3 support and hopefully fixed the composer issues to allow downloads of v1.1.2 (which should probably have been 1.1.3)

LRotherfield avatar Mar 31 '16 19:03 LRotherfield

@djcvijic can you confirm that updating the commit for tag 1.1.2 is likely to break installations for people using composer install from current composer.lock files? Will they need delete the source and run composer update to get the latest version?

LRotherfield avatar Mar 31 '16 19:03 LRotherfield

Since 1.1.2 was not propagating to packagist anyway, moving the tag has not broken anything. And since those of us using the legacy revision need to change our composer config from "lrotherfield/form" : "dev-master#799597f", to "lrotherfield/form" : "1.1.2",, we're expected to run a composer update anyway for the change to take effect, so I think everyone will be fine with that. Thanks again!

djcvijic avatar Apr 01 '16 10:04 djcvijic