Nested collection fields in Sonata Admin (2.3)

后端 未结 2 796
感情败类
感情败类 2021-02-05 05:13

I\'m having problems creating my form for creating a course. This is a part of my database scheme for which I\'m trying to create a form:

So which I\'m trying t

2条回答
  •  春和景丽
    2021-02-05 05:50

    public function getChildFormBuilder(FormBuilder $formBuilder, $elementId)
    {
        foreach (new FormBuilderIterator($formBuilder) as $name => $formBuilder) {
            if ($name == $elementId) {
                return $formBuilder;
            }
        }
        return;
    }
    

    Dumping the name and element id within the loop won't accomplish anything. Your application obviously crashes when there is nothing to iterate - it then walks through the loop, exits and goes to the last line where NULL is returned.

    I suggest you dump the element id just after the loop, like the following. The use of debug_backtrace might also help:

    public function getChildFormBuilder(FormBuilder $formBuilder, $elementId)
    {
        foreach (new FormBuilderIterator($formBuilder) as $name => $formBuilder) {
            if ($name == $elementId) {
                return $formBuilder;
            }
        }
    
    var_dump(__METHOD__);
    var_dump($elementId);
    var_dump(debug_backtrace());
    
        return;
    }
    

提交回复
热议问题