dcat-admin icon indicating copy to clipboard operation
dcat-admin copied to clipboard

setConstraints方法在进入表单后,无法关联到List按钮

Open kinber126 opened this issue 3 years ago • 2 comments

  • Laravel Version: 9.1.9
  • PHP Version:8.1
  • Dcat Admin Version: 2.2.2

Description:

使用setConstraints传参,新增、编辑等能正常使用,但是进入表单后,List按钮没有附带参数,造成点击返回后报错。

Steps To Reproduce:

现在处理的方法是在Form/Tools.php中将Grid/Model.php中的方法 setConstraints getConstraints 复制进入,并修改了getListPath的代码。

望,修改一下代码中:)

kinber126 avatar Jul 22 '22 08:07 kinber126

发个 Demo 看看

laradocs avatar Jul 23 '22 02:07 laradocs

发个 Demo 看看

    /**
     * Get request path for resource list.
     *
     * @return string
     */
    protected function getListPath()
    {
        $queryString = '';
        if ($constraints = $this->getConstraints()) {
            $queryString = http_build_query($constraints);
        }

        $url = $this->form->resource();
        return $url.($queryString ? ('?'.$queryString) : '');
    }


    /**
     * Get constraints.
     *
     * @return array|bool
     */
    public function getConstraints()
    {
        return $this->constraints;
    }

    /**
     * @param  array  $constraints
     * @return $this
     */
    public function setConstraints(array $constraints)
    {
        $this->constraints = $constraints;

        return $this;
    }

    
    /**
     * Get request path for delete.
     *
     * @return string
     */
    protected function getViewPath()
    {
        if ($key = $this->form->getResourceId()) {
            return $this->form->resource().'/'.$key;
        }

        return $this->getListPath();
    }

方法:getConstraints,setConstraints 为新增方法,其它为修改内容

kinber126 avatar Jul 23 '22 08:07 kinber126

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 22 '23 03:01 stale[bot]