WebinoImageThumb icon indicating copy to clipboard operation
WebinoImageThumb copied to clipboard

form fieldset issue

Open ceadreak opened this issue 8 years ago • 1 comments

Hi,

I have a problem with this module when using form collection in my application.

This works great, but if a form contains a collection, an error is thrown : Zend\Form\FormElementManager::get was unable to fetch or create an instance for my.fieldset.form.config.key

An example to reproduce it :

  • Create a form collection and insert it in a form

        $this->add([
            'type'    => Collection::class,
            'name'    => 'categories',
            'options' => [
                'label'                  => 'Categories,
                'count'                  => 0,
                'should_create_template' => true,
                'allow_add'              => true,
                'create_new_objects'     => true,
                'target_element'         =>
                    [
                        'type' => 'categories.fieldset',
                    ],
            ],
        ]);
    
  • Define the fieldset

    class CategoryFieldset extends \Zend\Form\Fieldset
    {
        // fieldset fields definition ....
    }
    
  • Define the configuration in the form config file

    'categories.fieldset'                        => function ($sl)
                {
                    $fieldset = new CategoryFieldset();
                    $fieldset->setHydrator(new ClassMethods());
                    $fieldset->setObject(new Category());
    
                    return $fieldset;
                },
    

So for now, instead of add the ImageThumb module in the application config and inject the ImageThumbService from serviceLocator to my controllers, I just create a new instance.

Cheers, Ceadreak

ceadreak avatar May 17 '16 09:05 ceadreak

Hi, thank you for your report. Could you please provide a better use case that I can test and find the bug. I cant imagine how a form fieldset chould be related to the image thumb service. Thanks.

bacinsky avatar Jun 08 '16 09:06 bacinsky