If you’ve ever used X-Editable, you’ll have noticed that it doesn’t play nice with Yii’s CActiveForm naming conventions. The included Action is a bit kludgy - if you already have update actions in place, especially if they handle errors intelligently, why create a new one?
I wrote a simple filter - RESTXEditableFilter - that maps the X-Editable POST format to the format your controllers are probably already using.
Here’s what it does:
[list=1]
[*]Detect if the request is an X-Editable request
[*]Map the X-Editable parameters to the normal format
[*]Unset the X-Editable params
* Forward to another action to handle the normalized request
[/list]
And here’s what it does to the HTTP request:
// X-Editable (original)
POST /some/url
pk=123&name=firstname&value=Daniel
// Filtered using the prefix "Customer"
POST /some/url?id=123
Customer[firstname]=Daniel