Note that there are some explanatory texts on larger screens.

plurals
  1. POzf2 restful not reach update method
    text
    copied!<p>I made a restful controller that if I send the id the get method receives it. But when I update a form I expect the update method to process but I cant get to the right config for this and after 1 day with this issue I decided to right it down here.</p> <p>Here the code involved route in module config:</p> <pre><code> 'activities' =&gt; array( 'type' =&gt; 'segment', 'options' =&gt; array( 'route' =&gt; '/activities[/:id][/:action][.:formatter]', 'defaults' =&gt; array( 'controller' =&gt; 'activities' ), 'constraints' =&gt; array( 'formatter' =&gt; '[a-zA-Z0-9_-]*', 'id' =&gt; '[0-9_-]*' ), ), ), </code></pre> <p>Head of controller:</p> <pre><code>namespace Clock\Controller; use Zend\Mvc\Controller\AbstractRestfulController; use Zend\Mvc\MvcEvent; use Zend\View\Model\ViewModel; use Zend\Form\Annotation\AnnotationBuilder; use Zend\Form; use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityRepository; use Clock\Entity\Activity; use \Clock\Entity\Project; Wich contains the get method: public function get($id) { $entity = $this-&gt;getRepository()-&gt;find($id); $form = $this-&gt;buildForm(new Activity()); #$form-&gt;setAttribute('action', $this-&gt;url()-&gt;fromRoute("activities", array('action' =&gt; 'update'))); $form-&gt;setAttribute('action', "/activities/$id/update"); $form-&gt;bind($entity); return array( "activities" =&gt; $entity, "form" =&gt; $form ); } </code></pre> <p>That feeds this view:</p> <pre><code>&lt;h3&gt;Edit activity&lt;/h3&gt; &lt;div&gt; &lt;?php echo $this-&gt;form()-&gt;openTag($form);?&gt; &lt;?php echo $this-&gt;formSelect($form-&gt;get("project"));?&gt;&lt;br&gt; &lt;?php echo $this-&gt;formInput($form-&gt;get("duration"));?&gt;&lt;br&gt; &lt;?php echo $this-&gt;formInput($form-&gt;get("description"));?&gt;&lt;br&gt; &lt;input type="submit" value="save changes" /&gt; &lt;?php echo $this-&gt;form()-&gt;closeTag($form);?&gt; &lt;/div&gt; </code></pre> <p>After sending it, I expect update method in activities to take control, but I get:</p> <pre><code>A 404 error occurred Page not found. The requested controller was unable to dispatch the request. Controller: activities </code></pre> <p>EDIT:@DrBeza This is what i get, that i think (not a master in routes) is right:</p> <pre><code>Zend\Mvc\Router\Http\RouteMatch Object ( [length:protected] =&gt; 21 [params:protected] =&gt; Array ( [controller] =&gt; activities [id] =&gt; 30 [action] =&gt; update ) [matchedRouteName:protected] =&gt; activities ) </code></pre> <p>--</p> <p>That's it. Any help?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload