Hello,
I've succesfully followed the "Developing and Extra" tutorial, up to the end of part II (
http://rtfm.modx.com/revolution/2.x/case-studies-and-tutorials/developing-an-extra-in-modx-revolution/developing-an-extra-in-modx-revolution,-part-ii). Well, almost succesfully.
I'm stuck in the last passage, the "update from grid". It looks like the upgradeFromGrid.class.php example from the tutorial is completely off: the ajax call receives a simple 'DoodleUpdateFromGridProcessor' plain text response, instead of, I would imagine, a JSON object.
Other sources offer very different upgradeFromGrid.class.php examples, eg.:
https://forums.modx.com/thread/87174/make-grid-field-editable#dis-post-480254
https://github.com/bertoost/MODX-Polls/blob/master/core/components/polls/processors/mgr/questions/updatefromgrid.php
Who is right, who is wrong? Is there any updated and tested documentation for working with updates from grid? I searched but I couldn't find any.
Thank you for the clarification,
Manuele Sarfatti
--
MODX Revolution 2.2.14-pl (traditional)
You might find this helpful:
http://bobsguides.com/blog.html/2013/11/21/modx-cmps-an-anatomy-lesson/.
If you're not getting a JSON string back from the Ajax request (you can see the response in Chrome Dev. tools), there's a missing step somewhere where $modx->toJSON() should be being called for the array.
discuss.answer
Ok I can't believe it, just lost a whole morning for a stupid naming mistake.
My file was called upgradeFromGrid.php instead of upgradeFromGrid.class.php and for whatever reason MODX didn't like it. Didn't give any useful errore response either though...
Anyway thanks for the support!
--
MODX Revolution 2.2.14-pl (traditional)
MODX looks for a class file first, and uses the old-style version you had originally if it can't find one. I think yours might have worked if you had called $modx->toJSON() on the return value. I think the parent class does it for you if you use a class-based processor, which is the preferred method now.