I create a from statically in HTML file in view project which is inside the module visit. I want the controller to handle the request occur when submitting the form
<form action="addVisit" method="post">
<input type="text" name="number"/>
<input type="submit" name="save"/>
The structure of the project is
module visits
controller Visits and it has action addVisit
when submitting the form an error occur, the url becomes like this when submitting the form
http://localhost/zendApps/InspectionSys/public/visits/visits/VisitsController/addVisit
in the controller there is a function action
public function addVisitAction()
{
echo 'here';
}
what should I do ?
First you might reconsider camel caseing your actions addVisitAction()
because if you do then you have to deal with view file names like add-visit.phtml
I think it will affect urls as well, I find it simpler just to leave action names as lowercase addvisitAction()
, this might be part of what's amiss.
Next identify your form actions as /module/controller/action
(if you are not using modules you can omit that param), so your action should at least be /visits/visits/addvisit
or /visits/visits/add-visit
(not quite sure which will work properly) .
also when using html forms that were not generated by Zend_Form you can access the values using $this->getParams()
or $this->getParam('paramName')
instead of $this->getValues()
.
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.