webwingscz/FormsReplicator

default values and createdefault error

Closed this issue · 0 comments

default values and createdefault error

I Have code

        $directors = $form->addDynamic(
            'directors',
            function (Container $cont) {
               $container->addSelect('id','director', $this->getDirectorList() )
                ...
             },1,true
        );
        ...
        $defaults = []
        foreach ($directors as $director)
        {
             $defaults['directors'][] = ['id' => $director['id']];
        }

        $form->setDefaults($defaults);

Expecting

Form with selects count == count($directors) prefilled or 1 empty if count($directors) == 0

Getting

InvalidArgumentException("Container with name 0 already exists.");