2

我正在使用Yii2 DynamicForms 扩展 来创建没有问题的动态字段,但是今天当我运行 composer update 我收到以下错误:

Call to undefined method Symfony\Component\DomCrawler\Crawler::rewind()

错误指向第 201 行/vendor/wbraganca/yii2-dynamicform/DynamicFormWidget.php

private function removeItems($content)
{
    $document = new \DOMDocument('1.0', \Yii::$app->charset);
    $crawler = new Crawler();
    $crawler->addHTMLContent($content, \Yii::$app->charset);
    $root = $document->appendChild($document->createElement('_root'));
    $crawler->rewind(); // Error here
    $root->appendChild($document->importNode($crawler->current(), true));
    $domxpath = new \DOMXPath($document);
    $crawlerInverse = $domxpath->query(CssSelector::toXPath($this->widgetItem));

    foreach ($crawlerInverse as $elementToRemove) {
        $parent = $elementToRemove->parentNode;
        $parent->removeChild($elementToRemove);
    }

    $crawler->clear();
    $crawler->add($document);
    return $crawler->filter('body')->eq(0)->html();
}

此方法已从 DomCrawler 中删除?
如何解决这个问题?

4

1 回答 1

2

另一种解决方案是将 DomCrawler 恢复到 2.8 版。

{
    "symfony/dom-crawler": "2.8",
    "symfony/css-selector": "2.8",
    "wbraganca/yii2-dynamicform": "2.0.1"
}

取自: https ://github.com/wbraganca/yii2-dynamicform/issues/108

于 2016-02-12T16:33:46.490 回答