⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Return error or debug messages when using before insert



Matthew Collins
  • profile picture
  • Member

Posted 24 October 2012 - 00:51 AM

Trying to use callback_before_insert() -- that part works.

However, I have some complicated coding to do for this piece and I'm having trouble sending back error or debug messages -- getting JSON syntax errors in firebug.

Any advice for sending debug messages back to the screen?

Matthew Collins
  • profile picture
  • Member

Posted 24 October 2012 - 22:34 PM

So --- perhaps I can explain a bit further.

I have my video controller that has a call to: $this->grocery_crud->callback_before_insert(array($this->video_model,'save'));

In the video model, I have calls to outside API's I have to make using curl.

Since the save function is using ajax (and since this involves a file upload, so I can't turn off javascript) -- I try to echo the messages back; however, when I do that, I get a json syntax error.

I see I can do this: return json_encode(array('success' => true , 'success_message' => "test"));
However, even this is very sensitive to syntax.

Any suggestions are appreciated.

Thanks,

Luis Sacristán
  • profile picture
  • Member

Posted 26 October 2012 - 16:39 PM

Hi

I have the same issue, I'm going to try to set a set_rules in the id field and check in the function if I can save or update the record.

Hope it helps you

Luis

Matthew Collins
  • profile picture
  • Member

Posted 26 October 2012 - 17:03 PM

Luis -- Thanks for your response -- what I ended up doing was building a controller I could hit to test the application, using stub data. That let me debug.

Not the best of solutions -- but it got it done.