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.
Make simple post request to "/domainname/nl/profile/info" and watch for response headers. Or you can analyze existing requests with tcpdump or something simular
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
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.