duanlu2935 2013-11-15 10:03
浏览 22
已采纳

Yii路由表格动作

I have a problem where, when submitting my form, it seems to ignore my routing and redirects me to the Home instead.

In my main.php routing:

'<language\w+>/profile/<slug:[\w\-]+>'  => 'profile/index',
'<language\w+>/<action:\w+>'            => 'site/index',

My form:

<form action="<?php echo Yii::app()->getBaseUrl()."/".Yii::app()->language;?>
/profile/calendar" method="post">

Which outputs to

<form action="/domainname/nl/profile/calendar" method="post">

Note: domainname is there because I'm testing this on localhost.

However, when pressing the submit button it forwards me to the home instead of the correct page. Simply visiting /domainname/nl/profile/calendar in the browser does work and gives me the correct controller. I don't know why it isn't working in the form.

In a different form on the same website, I have the following, which again does work fine for the routing:

<form action="/domainname/nl/profile/info" method="post">

The difference between these 2 forms is that the last one is created through CActiveForm widget and the first one isn't.

  • 写回答

2条回答 默认 最新

  • dtc66318 2014-02-17 09:11
    关注

    I managed to work around the issue by switching my manual form to use the CActiveForm widget after all. It seems I needed the yii_cs_csrf_token that is automatically generated by CActiveForm.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵