Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP ZF2 - Restful controller Backbone PUT method incorrect parsing
    primarykey
    data
    text
    <p>I have an issue with my ZF2 based application and Backbone at frontend. Somewhere at frontent I run</p> <pre><code>this.model.save({ city_id: parseInt( this.$el.find( '#city_id' ).val() ), from: this.$el.find( '#from' ).val(), to: this.$el.find( '#to' ).val(), price: parseInt( this.$el.find( '#price' ).val() ) }); </code></pre> <p>I turn on my Chrome sniffer and see the request details:</p> <pre><code>PUT /account/trip/2 HTTP/1.1 Host: jamydays.ru Connection: keep-alive Content-Length: 186 Accept: application/json, text/javascript, */*; q=0.01 Origin: http://jamydays.ru X-Requested-With: XMLHttpRequest User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31 Content-Type: application/json Referer: http://jamydays.ru/account Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 Cookie: PHPSESSID=pekjbefmi1jn01q5fgm4gu6jk0; _ym_visorc=w </code></pre> <p>And request payload is:</p> <pre><code>{"from_formatted":"10 маÑ","to_formatted":"19 маÑ","url":"/account/trip","id":2,"city_id":65170,"city":"Baardheere","from":"10-05-2013","to":"19-05-2013","price":500,"is_active":1} </code></pre> <p>Conroller used to handle this request runs appropriate action:</p> <pre><code>class TripController extends AbstractRestfulController{ ... public function update( $id, $data ){ var_dump( $id, $data );exit(); } ... } </code></pre> <p>My trouble is that I see in result this:</p> <pre><code>string(1) "2" array(1) { ["{"from_formatted":"10_мая","to_formatted":"19_мая","url":"/account/trip","id":2,"city_id":65170,"city":"Baardheere","from":"10-05-2013","to":"19-05-2013","price":500,"is_active":1}"]=&gt; string(0) "" } </code></pre> <p>Here we see that id parsed good, but all data fall into key of some strange array. Now I am retrieving data from this key, but guess this is bad way. Could anybody help me to figure out how to make controller parse data appropriate.</p> <p>UPDATE</p> <p>Well it seems the solution is just to update ZF2 to 2.2 stable version.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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