问题
My app seems to be completely ignoring the PUT action. I have a controller with GET, POST, PUT and DELETE actions using REST. Both PUT and DELETE methods seem to be ignored. Perhaps it's an action and method syntax issue?
Anyway here is some sample code:
public function init()
{
// Set the method for the display form to PUT
$this->setMethod('PUT');
$this->setAction('/article/?update');
}
From Controller:
public function putAction()
{
echo "putAction";exit();
}
In my .htaccess I also allow from all GET POST PUT DELETE
I'm confused, it's not working. Please can you help, thanks again!
This is the form:
<form articleid="17" articlename="1" articlecontent="1" topicidfk="1" topicid="1" topicname="Sports" method="put" action="/article?update"><dl class="zend_form">
<dt id="articlename-label"><label for="articlename" class="required">Article Name</label></dt>
<dd id="articlename-element">
<input type="text" name="articlename" id="articlename" value="1" /></dd>
<dt id="articlecontent-label"><label for="articlecontent" class="required">Article Content</label></dt>
<dd id="articlecontent-element">
<textarea name="articlecontent" id="articlecontent" rows="4" cols="80">1</textarea></dd>
<dt id="topicidfk-label"> </dt>
<dd id="topicidfk-element">
<select name="topicidfk" id="topicidfk">
<option value="0" label="Select One">Select One</option>
<option value="1" label="Sports" selected="selected">Sports</option>
<option value="2" label="Finance">Finance</option>
</select></dd>
<dt id="submit-label"> </dt><dd id="submit-element">
<input type="submit" name="submit" id="submit" value="Update Article" /></dd></dl></form>
回答1:
This post Examples on Zend_Rest_Controller Unit Testing - seems to have helped although it looks like a bit of hack but I'll take it for now!
来源:https://stackoverflow.com/questions/13034145/zend-method-put