GithubHelp home page GithubHelp logo

Comments (2)

josemsalves avatar josemsalves commented on July 28, 2024

https://github.com/josemsalves/testes

from doctrine-laminas-hydrator.

driehle avatar driehle commented on July 28, 2024

@josemsalves

I had a short look in your sample code, but the code under https://github.com/josemsalves/testes has several other (non-related) issues - a simple docker compose up -d doesn't get it running to repreduce the error you mentioned above. Please note that your application is outdated, as it is still using PHP 7.4. I recommend re-creating the project from the laminas-skeleton-application, to enable use of PHP 8.1.

Regarding your error message Call to a member function setValue() on null, you should provide a traceback to show the relevant class/method where the error occurs. One think that I see as problematic in your code snippets above is that you are creating the fieldsets with new ClassName(). Please take a look at the Laminas form documentation on how to use custom elements: https://docs.laminas.dev/laminas-form/v3/advanced/#creating-custom-elements. Elements should be created through the form factory, which initializes the elements correctly.

You should do something like this:

        $this->add([
            'type' => \Laminas\Form\Element\Collection::class,
            'name' => 'mySubFieldsetElement',
            'options' => [
                'allow_add' => true,
                'allow_remove' => true,
                'target_element' => [
                    'type' => \Application\Form\MySubFieldset::class,
                ],
            ],
        ]);

Or, in case you need the target element object itself, try this:

        $targetElement = $this->getFormFactory()->getFormElementManager()->get(\Application\Form\MySubFieldset::class);
        $this->add([
            'type' =>  \Laminas\Form\Element\Collection::class,
            'name' => 'mySubFieldsetElement',
            'options' => [
                'allow_add' => true,
                'allow_remove' => true,
                'target_element' => $targetElement,
            ],
        ]);

from doctrine-laminas-hydrator.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.