dougu9895 2014-11-29 17:09
浏览 627
已采纳

Yii2 - yii \ base \ InvalidRouteException

I'm trying to do an aplication with Yii2 and when I add a new action to the default controller:

public function actionMostrarArticle($id)
{

    $article = (new Query)->select('*')->from('subasta_actual')->where('id = :id');
    $article->addParams([':id' => $id]);

    $imatges = obtenir_imatges_active_from_objecteId($id);

    return $this->render('article',['article' => $article, 'imatges' => $imatges]);

}

and I ask for it:

<a href="<?=Url::toRoute(['site/mostrarArticle', 'id' => $model->id]);?>">Me interesa</a>

I have the exception:

exception 'yii\base\InvalidRouteException' with message 'Unable to resolve the request: site/mostrarArticle' inexception 'yii\base\InvalidRouteException' with message 'Unable to resolve the request: site/mostrarArticle'

Can anyone helps me?

Thanks!

Toni

  • 写回答

1条回答 默认 最新

  • dqrl3595 2014-11-29 19:07
    关注

    You should create a url for that route as follows:

    <?= Url::toRoute(['site/mostrar-article', 'id' => $model->id]) ?>
    

    It is explained here

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 scottplot5
  • ¥15 想问问这个建模怎么编程没有思路
  • ¥15 关于imageENview(ImageEN)中新建图层并根据鼠标位置添加图标
  • ¥100 用两台电脑局域联网进行MT5的EA参数优化,但是连接不上
  • ¥15 FastAPI报错: AsyncSession不是有效Pydantic类型
  • ¥50 这Mac系统提示虚拟内存不足,怎么解决
  • ¥15 Rs232电路无法收发数据,求帮助
  • ¥15 百度cookie扫码登录器
  • ¥15 微机原理汇编语言debug调试实验
  • ¥23 matlab可以把相图转换为庞加莱映射吗